You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apex.apache.org by th...@apache.org on 2016/03/04 17:15:09 UTC

[01/11] incubator-apex-core git commit: Migrating docs [Forced Update!]

Repository: incubator-apex-core
Updated Branches:
  refs/heads/APEXCORE-293 f863aaf19 -> 333313b59 (forced update)


http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/images/AppConfig/ApplicationConfigurationPackages.html-image02.png
----------------------------------------------------------------------
diff --git a/images/AppConfig/ApplicationConfigurationPackages.html-image02.png b/images/AppConfig/ApplicationConfigurationPackages.html-image02.png
deleted file mode 100644
index 65a8aee..0000000
Binary files a/images/AppConfig/ApplicationConfigurationPackages.html-image02.png and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/images/AppPackage/ApplicationPackages.html-image00.png
----------------------------------------------------------------------
diff --git a/images/AppPackage/ApplicationPackages.html-image00.png b/images/AppPackage/ApplicationPackages.html-image00.png
deleted file mode 100644
index 5b3623d..0000000
Binary files a/images/AppPackage/ApplicationPackages.html-image00.png and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/images/AppPackage/ApplicationPackages.html-image01.png
----------------------------------------------------------------------
diff --git a/images/AppPackage/ApplicationPackages.html-image01.png b/images/AppPackage/ApplicationPackages.html-image01.png
deleted file mode 100644
index f707d81..0000000
Binary files a/images/AppPackage/ApplicationPackages.html-image01.png and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/images/AppPackage/ApplicationPackages.html-image02.png
----------------------------------------------------------------------
diff --git a/images/AppPackage/ApplicationPackages.html-image02.png b/images/AppPackage/ApplicationPackages.html-image02.png
deleted file mode 100644
index 49de0e9..0000000
Binary files a/images/AppPackage/ApplicationPackages.html-image02.png and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/images/MalharOperatorOverview.png
----------------------------------------------------------------------
diff --git a/images/MalharOperatorOverview.png b/images/MalharOperatorOverview.png
deleted file mode 100644
index 40bee4a..0000000
Binary files a/images/MalharOperatorOverview.png and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/images/apex_logo.png
----------------------------------------------------------------------
diff --git a/images/apex_logo.png b/images/apex_logo.png
deleted file mode 100644
index baa25ca..0000000
Binary files a/images/apex_logo.png and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/images/application_development/ApplicationDeveloperGuide.html-image00.png
----------------------------------------------------------------------
diff --git a/images/application_development/ApplicationDeveloperGuide.html-image00.png b/images/application_development/ApplicationDeveloperGuide.html-image00.png
deleted file mode 100644
index 87ebce4..0000000
Binary files a/images/application_development/ApplicationDeveloperGuide.html-image00.png and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/images/application_development/ApplicationDeveloperGuide.html-image01.png
----------------------------------------------------------------------
diff --git a/images/application_development/ApplicationDeveloperGuide.html-image01.png b/images/application_development/ApplicationDeveloperGuide.html-image01.png
deleted file mode 100644
index 4cdee33..0000000
Binary files a/images/application_development/ApplicationDeveloperGuide.html-image01.png and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/images/application_development/ApplicationDeveloperGuide.html-image02.png
----------------------------------------------------------------------
diff --git a/images/application_development/ApplicationDeveloperGuide.html-image02.png b/images/application_development/ApplicationDeveloperGuide.html-image02.png
deleted file mode 100644
index 5bf041c..0000000
Binary files a/images/application_development/ApplicationDeveloperGuide.html-image02.png and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/images/application_development/ApplicationDeveloperGuide.html-image03.png
----------------------------------------------------------------------
diff --git a/images/application_development/ApplicationDeveloperGuide.html-image03.png b/images/application_development/ApplicationDeveloperGuide.html-image03.png
deleted file mode 100644
index e00bba5..0000000
Binary files a/images/application_development/ApplicationDeveloperGuide.html-image03.png and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/images/application_development/ApplicationDeveloperGuide.html-image04.png
----------------------------------------------------------------------
diff --git a/images/application_development/ApplicationDeveloperGuide.html-image04.png b/images/application_development/ApplicationDeveloperGuide.html-image04.png
deleted file mode 100644
index 8f62361..0000000
Binary files a/images/application_development/ApplicationDeveloperGuide.html-image04.png and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/images/application_development/ApplicationDeveloperGuide.html-image05.png
----------------------------------------------------------------------
diff --git a/images/application_development/ApplicationDeveloperGuide.html-image05.png b/images/application_development/ApplicationDeveloperGuide.html-image05.png
deleted file mode 100644
index f9ea8d9..0000000
Binary files a/images/application_development/ApplicationDeveloperGuide.html-image05.png and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/images/application_development/ApplicationDeveloperGuide.html-image06.png
----------------------------------------------------------------------
diff --git a/images/application_development/ApplicationDeveloperGuide.html-image06.png b/images/application_development/ApplicationDeveloperGuide.html-image06.png
deleted file mode 100644
index 346690c..0000000
Binary files a/images/application_development/ApplicationDeveloperGuide.html-image06.png and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/images/application_development/ApplicationDeveloperGuide.html-image07.png
----------------------------------------------------------------------
diff --git a/images/application_development/ApplicationDeveloperGuide.html-image07.png b/images/application_development/ApplicationDeveloperGuide.html-image07.png
deleted file mode 100644
index e57a8eb..0000000
Binary files a/images/application_development/ApplicationDeveloperGuide.html-image07.png and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/images/application_development/ApplicationDeveloperGuide.html-image08.png
----------------------------------------------------------------------
diff --git a/images/application_development/ApplicationDeveloperGuide.html-image08.png b/images/application_development/ApplicationDeveloperGuide.html-image08.png
deleted file mode 100644
index a363f94..0000000
Binary files a/images/application_development/ApplicationDeveloperGuide.html-image08.png and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/images/application_development/ApplicationDeveloperGuide.html-image09.png
----------------------------------------------------------------------
diff --git a/images/application_development/ApplicationDeveloperGuide.html-image09.png b/images/application_development/ApplicationDeveloperGuide.html-image09.png
deleted file mode 100644
index 8a0252b..0000000
Binary files a/images/application_development/ApplicationDeveloperGuide.html-image09.png and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/images/autometrics/adt.png
----------------------------------------------------------------------
diff --git a/images/autometrics/adt.png b/images/autometrics/adt.png
deleted file mode 100644
index 187bbd4..0000000
Binary files a/images/autometrics/adt.png and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/images/autometrics/dashboard.png
----------------------------------------------------------------------
diff --git a/images/autometrics/dashboard.png b/images/autometrics/dashboard.png
deleted file mode 100644
index c4ebb39..0000000
Binary files a/images/autometrics/dashboard.png and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/images/autometrics/visualize.png
----------------------------------------------------------------------
diff --git a/images/autometrics/visualize.png b/images/autometrics/visualize.png
deleted file mode 100644
index fb2e780..0000000
Binary files a/images/autometrics/visualize.png and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/images/operator/image00.png
----------------------------------------------------------------------
diff --git a/images/operator/image00.png b/images/operator/image00.png
deleted file mode 100644
index 14588aa..0000000
Binary files a/images/operator/image00.png and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/images/operator/image01.png
----------------------------------------------------------------------
diff --git a/images/operator/image01.png b/images/operator/image01.png
deleted file mode 100644
index 626c6b5..0000000
Binary files a/images/operator/image01.png and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/images/operator/image02.png
----------------------------------------------------------------------
diff --git a/images/operator/image02.png b/images/operator/image02.png
deleted file mode 100644
index 2be9433..0000000
Binary files a/images/operator/image02.png and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/images/operator/image03.png
----------------------------------------------------------------------
diff --git a/images/operator/image03.png b/images/operator/image03.png
deleted file mode 100644
index 67802d8..0000000
Binary files a/images/operator/image03.png and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/images/operator/image04.png
----------------------------------------------------------------------
diff --git a/images/operator/image04.png b/images/operator/image04.png
deleted file mode 100644
index 58d99d9..0000000
Binary files a/images/operator/image04.png and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/images/operator/image05.png
----------------------------------------------------------------------
diff --git a/images/operator/image05.png b/images/operator/image05.png
deleted file mode 100644
index 9ac6f21..0000000
Binary files a/images/operator/image05.png and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/operator_development.md
----------------------------------------------------------------------
diff --git a/operator_development.md b/operator_development.md
deleted file mode 100644
index f502725..0000000
--- a/operator_development.md
+++ /dev/null
@@ -1,449 +0,0 @@
-Operator Development Guide
-==========================
-
-Operators are basic building blocks of an application built to run on
-Apache Apex platform. An application may consist of one or more
-operators each of which define some logical operation to be done on the
-tuples arriving at the operator. These operators are connected together
-using streams forming a Directed Acyclic Graph (DAG). In other words, a streaming
-application is represented by a DAG that consists of operations (called operators) and
-data flow (called streams).
-
-In this document we will discuss details on how an operator works and
-its internals. This document is intended to serve the following purposes
-
-1.  **[Apache Apex Operators](#apex_operators)** - Introduction to operator terminology and concepts.
-2.  **[Writing Custom Operators](#writing_custom_operators)** - Designing, coding and testing new operators from scratch.  Includes code examples.
-3.  **[Operator Reference](#operator_reference)** - Details of operator internals, lifecycle, and best practices and optimizations.
-
-* * * * *
-
-Apache Apex Operators <a name="apex_operators"></a>
-==========================================
-
-Operators - “What” in a nutshell
---------------------------------
-
-Operators are independent units of logical operations which can
-contribute in executing the business logic of a use case. For example,
-in an ETL workflow, a filtering operation can be represented by a single
-operator. This filtering operator will be responsible for doing just one
-task in the ETL pipeline, i.e. filter incoming tuples. Operators do not
-impose any restrictions on what can or cannot be done as part of a
-operator. An operator may as well contain the entire business logic.
-However, it is recommended, that the operators are light weight
-independent tasks, in
-order to take advantage of the distributed framework that Apache Apex
-provides. The structure of a streaming application shares resemblance
-with the way CPU pipelining works. CPU pipelining breaks down the
-computation engine into different stages viz. instruction fetch,
-instruction decode, etc. so that each of them can perform their task on
-different instructions
-parallely. Similarly,
-Apache Apex APIs allow the user to break down their tasks into different
-stages so that all of the tasks can be executed on different tuples
-parallely.
-
-![](images/operator/image05.png)
-
-Operators - “How” in a nutshell
--------------------------------
-
-An Apache Apex application runs as a YARN application. Hence, each of
-the operators that the application DAG contains, runs in one of the
-containers provisioned by YARN. Further, Apache Apex exposes APIs to
-allow the user to request bundling multiple operators in a single node,
-a single container or even a single thread. We shall look at these calls
-in the reference sections [cite reference sections]. For now, consider
-an operator as some piece of code that runs on some machine of a YARN
-cluster.
-
-Types of Operators
-------------------
-
-An operator works on one tuple at a time. These tuples may be supplied
-by other operators in the application or by external sources,
-such as a database or a message bus. Similarly, after the tuples are
-processed, these may be passed on to other operators, or stored into an external system. 
-Therea are 3 type of operators based on function: 
-
-1.  **Input Adapter** - This is one of the starting points in
-    the application DAG and is responsible for getting tuples from an
-    external system. At the same time, such data may also be generated
-    by the operator itself, without interacting with the outside
-    world. These input tuples will form the initial universe of
-    data that the application works on.
-2.  **Generic Operator** - This type of operator accepts input tuples from
-    the previous operators and passes them on to the following operators
-    in the DAG.
-3.  **Output Adapter** - This is one of the ending points in the application
-    DAG and is responsible for writing the data out to some external
-    system.
-
-Note: There can be multiple operators of all types in an application
-DAG.
-
-Operators Position in a DAG
------------------------------------
-
-We may refer to operators depending on their position with respect to
-one another. For any operator opr (see image below), there are two types of operators.
-
-1.  **Upstream operators** - These are the operators from which there is a
-    directed path to opr in the application DAG.
-2.  **Downstream operators** - These are the operators to which there is a
-    directed path from opr in the application DAG.
-
-Note that there are no cycles formed in the application DAG.
-
-![](images/operator/image00.png)
-
-Ports
------
-
-Operators in a DAG are connected together via directed flows
-called streams. Each stream has end-points located on the operators
-called ports. Therea are 2 types of ports.
-
-1.  **Input Port** - This is a port through which an operator accepts input
-    tuples from an upstream operator.
-2.  **Output port** - This is a port through which an operator passes on the
-    processed data to downstream operators.
-
-Looking at the number of input ports, an Input Adapter is an operator
-with no input ports, a Generic operator has both input and output ports,
-while an Output Adapter has no output ports. At the same time, note that
-an operator may act as an Input Adapter while at the same time have an
-input port. In such cases, the operator is getting data from two
-different sources, viz. the input stream from the input port and an
-external source.
-
-![](images/operator/image02.png)
-
-* * * * *
-
-How Operator Works
-----------------------
-
-An operator passes through various stages during its lifetime. Each
-stage is an API call that the Streaming Application Master makes for an
-operator.  The following figure illustrates the stages through which an
-operator passes.
-
-![](images/operator/image01.png)
-
--   The _setup()_ call initializes the operator and prepares itself to
-    start processing tuples.
--   The _beginWindow()_ call marks the beginning of an application window
-    and allows for any processing to be done before a window starts.
--   The _process()_ call belongs to the _InputPort_ and gets triggered when
-    any tuple arrives at the Input port of the operator. This call is
-    specific only to Generic and Output adapters, since Input Adapters
-    do not have an input port. This is made for all the tuples at the
-    input port until the end window marker tuple is received on the
-    input port.
--   The _emitTuples()_ is the counterpart of _process()_ call for Input
-    Adapters.
-    This call is used by Input adapters to emit any tuples that are
-    fetched from the external systems, or generated by the operator.
-    This method is called continuously until the pre-configured window
-    time is elapsed, at which the end window marker tuple is sent out on
-    the output port.
--   The _endWindow()_ call marks the end of the window and allows for any
-    processing to be done after the window ends.
--   The _teardown()_ call is used for gracefully shutting down the
-    operator and releasing any resources held by the operator.
-
-Developing Custom Operators <a name="writing_custom_operators"></a>
-====================================
-
-About this tutorial
--------------------
-
-This tutorial will guide the user towards developing a operator from
-scratch. It includes all aspects of writing an operator including
-design, code and unit testing.
-
-Introduction
-------------
-
-In this tutorial, we will design and write, from scratch, an operator
-called Word Count. This operator will accept tuples of type String,
-count the number of occurrences for each word appearing in the tuple and
-send out the updated counts for all the words encountered in the tuple.
-Further, the operator will also accept a file path on HDFS which will
-contain the stop-words which need to be ignored when counting
-occurrences.
-
-Design
-------
-
-Design of the operator must be finalized before starting to write an
-operator. Many aspects including the functionality, the data sources,
-the types involved etc. need to be first finalized before writing the
-operator. Let us dive into each of these while considering the Word
-Count operator.
-
-### Functionality
-
-We can define the scope of operator functionality using the following
-tasks:
-
-1.  Parse the input tuple to identify the words in the tuple
-2.  Identify the stop-words in the tuple by looking up the stop-word
-    file as configured
-3.  For each non-stop-word in the tuple, count the occurrences in that
-    tuple and add it to a global counts
-
-Let’s consider an example. Suppose we have the following tuples flow
-into the Word Count operator.
-
-1.  _Humpty dumpty sat on a wall_
-2.  _Humpty dumpty had a great fall_
-
-Initially counts for all words is 0. Once the first tuple is processed,
-the counts that must be emitted are:
-
-``` java
-humpty - 1
-dumpty - 1
-sat - 1
-wall - 1
-```
-
-Note that we are ignoring the stop-words, “on” and “a” in this case.
-Also note that as a rule, we’ll ignore the case of the words when
-counting occurrences.
-
-Similarly, after the second tuple is processed, the counts that must be
-emitted are:
-
-``` java
-humpty - 2
-dumpty - 2
-great - 1
-fall - 1
-```
-
-Again, we ignore the words _“had”_ and _“a”_ since these are stop-words.
-
-Note that the most recent count for any word is correct count for that
-word. In other words, any new output for a word, invalidated all the
-previous counts for that word.
-
-### Inputs
-
-As seen from the example above, the following inputs are expected for
-the operator:
-
-1.  Input stream whose tuple type is String
-2.  Input HDFS file path, pointing to a file containing stop-words
-
-Only one input port is needed. The stop-word file will be small enough
-to be read completely in a single read. In addition this will be a one
-time activity for the lifetime of the operator. This does not need a
-separate input port.
-
-![](images/operator/image03.png)
-
-### Outputs
-
-We can define the output for this operator in multiple ways.
-
-1.  The operator may send out the set of counts for which the counts
-    have changed after processing each tuple.
-2.  Some applications might not need an update after every tuple, but
-    only after a certain time duration.
-
-Let us try and implement both these options depending on the
-configuration. Let us define a boolean configuration parameter
-_“sendPerTuple”_. The value of this parameter will indicate whether the
-updated counts for words need to be emitted after processing each
-tuple (true) or after a certain time duration (false).
-
-The type of information the operator will be sending out on the output
-port is the same for all the cases. This will be a _< key, value >_ pair,
-where the key is the word while, the value is the latest count for that
-word. This means we just need one output port on which this information
-will go out.
-
-![](images/operator/image04.png)
-
-Configuration
--------------
-
-We have the following configuration parameters:
-
-1.  _stopWordFilePath_ - This parameter will store the path to the stop
-    word file on HDFS as configured by the user.
-2.  _sendPerTuple_ - This parameter decides whether we send out the
-    updated counts after processing each tuple or at the end of a
-    window. When set to true, the operator will send out the updated
-    counts after each tuple, else it will send at the end of
-    each window.
-
-Code
-----
-
-The source code for the tutorial can be found here:
-
-[https://github.com/DataTorrent/examples/tree/master/tutorials/operatorTutorial](https://www.google.com/url?q=https://github.com/DataTorrent/examples/tree/master/tutorials/operatorTutorial&sa=D&usg=AFQjCNHAAgSpNprHJVvy9GSjdlD1uwU7jw)
-
-
-Operator Reference <a name="operator_reference"></a>
-====================================
-
-
-### The Operator Class
-
-The operator will exist physically as a class which implements the
-Operator interface. This interface will require implementations for the
-following method calls:
-
--  setup(OperatorContext context)
--  beginWindow(long windowId)
--  endWindow()
--  tearDown()
-
-In order to simplify the creation of an operator, Apache Apex
-library also provides a base class “BaseOperator” which has empty
-implementations for these methods. Please refer to the [Apex Operators](#apex_operators) section and the
-[Reference](#operator_reference) section for details on these.
-
-We extend the class “BaseOperator” to create our own operator
-“WordCountOperator”.
-
-``` java
-public class WordCountOperator extends BaseOperator
-{
-}
-```
-
-### Class (Operator) properties
-
-We define the following class variables:
-
--   _sendPerTuple_ - Configures the output frequency from the operator
-``` java
-private boolean sendPerTuple = true; // default
-```
--   _stopWordFilePath_ - Stores the path to the stop words file on HDFS
-``` java
-private String stopWordFilePath; // no default
-```
--   _stopWords_ - Stores the stop words read from the configured file
-``` java
-private transient String[] stopWords;
-```
--   _globalCounts_ - A Map which stores the counts of all the words
-    encountered so far. Note that this variable is non transient, which
-    means that this variable is saved as part of the checkpoint and can be recovered in event of a crash.
-``` java
-private Map<String, Long> globalCounts;
-```
--   _updatedCounts_ - A Map which stores the counts for only the most
-    recent tuple(s). sendPerTuple configuration determines whether to store the most recent or the recent
-    window worth of tuples.
-``` java
-private transient Map<String, Long> updatedCounts;
-```
--   _input_ - The input port for the operator. The type of this input port
-    is String which means it will only accept tuples of type String. The
-    definition of an input port requires implementation of a method
-    called process(String tuple), which should have the processing logic
-    for the input tuple which  arrives at this input port. We delegate
-    this task to another method called processTuple(String tuple). This
-    helps in keeping the operator classes extensible by overriding the
-    processing logic for the input tuples.
-``` java
-public transient DefaultInputPort<String> input = new    
-DefaultInputPort<String>()
-{
-    @Override
-    public void process(String tuple)
-    {
-        processTuple(tuple);
-    }
-};
-```
--   output - The output port for the operator. The type of this port is
-    Entry < String, Long >, which means the operator will emit < word,
-    count > pairs for the updated counts.
-``` java
-public transient DefaultOutputPort <Entry<String, Long>> output = new
-DefaultOutputPort<Entry<String,Long>>();
-```
-
-### The Constructor
-
-The constructor is the place where we initialize the non-transient data
-structures, since
-constructor is called just once per activation of an operator. With regards to Word Count operator, we initialize the globalCounts variable in the constructor.
-``` java
-globalCounts = Maps.newHashMap();
-```
-### Setup call
-
-The setup method is called only once during an operator lifetime and its purpose is to allow 
-the operator to set itself up for processing incoming streams. Transient objects in the operator are
-not serialized and checkpointed. Hence, it is essential that such objects initialized in the setup call. 
-In case of operator failure, the operator will be redeployed (most likely on a different container). The setup method called by the Apache Apex engine allows the operator to prepare for execution in the new container.
-
-The following tasks are executed as part of the setup call:
-
-1.  Read the stop-word list from HDFS and store it in the
-    stopWords array
-2.  Initialize updatedCounts variable. This will store the updated
-    counts for words in most recent tuples processed by the operator.
-    As a transient variable, the value will be lost when operator fails.
-
-### Begin Window call
-
-The begin window call signals the start of an application window. With 
-regards to Word Count Operator, we are expecting updated counts for the most recent window of
-data if the sendPerTuple is set to false. Hence, we clear the updatedCounts variable in the begin window
-call and start accumulating the counts till the end window call.
-
-### Process Tuple call
-
-The processTuple method is called by the process method of the input
-port, input. This method defines the processing logic for the current
-tuple that is received at the input port. As part of this method, we
-identify the words in the current tuple and update the globalCounts and
-the updatedCounts variables. In addition, if the sendPerTuple variable
-is set to true, we also emit the words and corresponding counts in
-updatedCounts to the output port. Note that in this case (sendPerTuple =
-true), we clear the updatedCounts variable in every call to
-processTuple.
-
-### End Window call
-
-This call signals the end of an application window. With regards to Word
-Count Operator, we emit the updatedCounts to the output port if the
-sendPerTuple flag is set to false.
-
-### Teardown call
-
-This method allows the operator to gracefully shut down itself after
-releasing the resources that it has acquired. With regards to our operator,
-we call the shutDown method which shuts down the operator along with any
-downstream operators.
-
-Testing your Operator
----------------------
-
-As part of testing our operator, we test the following two facets:
-
-1.  Test output of the operator after processing a single tuple
-2.  Test output of the operator after processing of a window of tuples
-
-The unit tests for the WordCount operator are available in the class
-WordCountOperatorTest.java. We simulate the behavior of the engine by
-using the test utilities provided by Apache Apex libraries. We simulate
-the setup, beginWindow, process method of the input port and
-endWindow calls and compare the output received at the simulated output
-ports.
-
-1. Invoke constructor; non-transients initialized.
-2. Copy state from checkpoint -- initialized values from step 1 are
-replaced.


[07/11] incubator-apex-core git commit: APEXCORE-293 Adding Apex Core documentation

Posted by th...@apache.org.
APEXCORE-293 Adding Apex Core documentation


Project: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/commit/cfdacdf2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/tree/cfdacdf2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/diff/cfdacdf2

Branch: refs/heads/APEXCORE-293
Commit: cfdacdf295ea1ce198dc17a07582b9441785eb9d
Parents: 7af835b
Author: Sasha Parfenov <sa...@apache.org>
Authored: Fri Feb 26 17:12:29 2016 -0800
Committer: Thomas Weise <th...@datatorrent.com>
Committed: Sun Feb 28 22:49:38 2016 -0800

----------------------------------------------------------------------
 README.md                              |   2 +
 docs/README.md                         |  34 +++++++
 docs/apex.md                           |  14 ---
 docs/apex_development_setup.md         | 117 +++++++++-------------
 docs/apex_malhar.md                    |  64 ++++++------
 docs/application_development.md        | 140 ++++++--------------------
 docs/application_packages.md           |   8 +-
 docs/autometrics.md                    | 150 ++--------------------------
 docs/dtcli.md                          |   9 +-
 docs/favicon.ico                       | Bin 0 -> 25597 bytes
 docs/images/MalharOperatorOverview.png | Bin 297948 -> 0 bytes
 docs/index.md                          |  20 ++++
 docs/operator_development.md           |   8 +-
 mkdocs.yml                             |  15 +++
 14 files changed, 197 insertions(+), 384 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/cfdacdf2/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 4b22f71..97c2b03 100644
--- a/README.md
+++ b/README.md
@@ -11,6 +11,8 @@ Please visit the [documentation section](http://apex.incubator.apache.org/docs.h
 
 [Malhar](https://github.com/apache/incubator-apex-malhar) is a library of application building blocks and examples that will help you build out your first Apex application quickly.
 
+Documentation build and hosting process is explained in [docs/README.md].
+
 ##Contributing
 
 This project welcomes new contributors.  If you would like to help by adding new features, enhancements or fixing bugs, check out the [contributing guidelines](http://apex.incubator.apache.org/contributing.html).

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/cfdacdf2/docs/README.md
----------------------------------------------------------------------
diff --git a/docs/README.md b/docs/README.md
new file mode 100644
index 0000000..c9fe8da
--- /dev/null
+++ b/docs/README.md
@@ -0,0 +1,34 @@
+# Apex Documentation
+
+Apex documentation repository for content available on http://apex.incubator.apache.org/docs/
+
+Documentation is written in [Markdown](https://guides.github.com/features/mastering-markdown/) format and statically generated into HTML using [MkDocs](http://www.mkdocs.org/).  All documentation is located in the [docs](docs) directory, and [mkdocs.yml](mkdocs.yml) file describes the navigation structure of the published documentation.
+
+## Authoring
+
+New pages can be added under [docs](docs) or related sub-category, and a reference to the new page must be added to the [mkdocs.yml](mkdocs.yml) file to make it availabe in the navigation.  Embedded images are typically added to images folder at the same level as the new page.
+
+When creating or editing pages, it can be useful to see the live results, and how the documents will appear when published.  Live preview feature is available by running the following command at the root of the repository:
+
+```bash
+mkdocs serve
+```
+
+For additional details see [writing your docs](http://www.mkdocs.org/user-guide/writing-your-docs/) guide.
+
+## Site Configuration
+
+Guides on applying site-wide [configuration](http://www.mkdocs.org/user-guide/configuration/) and [themeing](http://www.mkdocs.org/user-guide/styling-your-docs/) are available on the MkDocs site.
+
+## Deployment
+
+**Under Review**: Current deployment process is under review, and may change from the one outlined below.
+
+
+Deployment is done from master branch of the repository by executing the following command:
+
+```bash
+mkdocs gh-deploy --clean
+```
+
+This results in all the documentation under [docs](docs) being statically generatd into HTML files and deployed as top level in [gh-pages](https://github.com/apache/incubating-apex-core/tree/gh-pages) branch.  For more details on how this is done see [MkDocs - Deploying Github Pages](http://www.mkdocs.org/user-guide/deploying-your-docs/#github-pages).
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/cfdacdf2/docs/apex.md
----------------------------------------------------------------------
diff --git a/docs/apex.md b/docs/apex.md
deleted file mode 100644
index 215a957..0000000
--- a/docs/apex.md
+++ /dev/null
@@ -1,14 +0,0 @@
-Apache Apex
-================================================================================
-
-Apache Apex (incubating) is the industry’s only open source, enterprise-grade unified stream and batch processing engine.  Apache Apex includes key features requested by open source developer community that are not available in current open source technologies.
-
-* Event processing guarantees
-* In-memory performance & scalability
-* Fault tolerance and state management
-* Native rolling and tumbling window support
-* Hadoop-native YARN & HDFS implementation
-
-For additional information visit [Apache Apex](http://apex.incubator.apache.org/).
-
-[![](images/apex_logo.png)](http://apex.incubator.apache.org/)

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/cfdacdf2/docs/apex_development_setup.md
----------------------------------------------------------------------
diff --git a/docs/apex_development_setup.md b/docs/apex_development_setup.md
index 777f2f9..0bbabc5 100644
--- a/docs/apex_development_setup.md
+++ b/docs/apex_development_setup.md
@@ -1,36 +1,29 @@
 Apache Apex Development Environment Setup
 =========================================
 
-This document discusses the steps needed for setting up a development environment for creating applications that run on the Apache Apex or the DataTorrent RTS streaming platform.
+This document discusses the steps needed for setting up a development environment for creating applications that run on the Apache Apex platform.
 
 
-Microsoft Windows
-------------------------------
+Development Tools
+-------------------------------------------------------------------------------
 
-There are a few tools that will be helpful when developing Apache Apex applications, some required and some optional:
+There are a few tools that will be helpful when developing Apache Apex applications, including:
 
-1.  *git* -- A revision control system (version 1.7.1 or later). There are multiple git clients available for Windows (<http://git-scm.com/download/win> for example), so download and install a client of your choice.
+1.  **git** - A revision control system (version 1.7.1 or later). There are multiple git clients available for Windows (<http://git-scm.com/download/win> for example), so download and install a client of your choice.
 
-2.  *java JDK* (not JRE). Includes the Java Runtime Environment as well as the Java compiler and a variety of tools (version 1.7.0\_79 or later). Can be downloaded from the Oracle website.
+2.  **java JDK** (not JRE) - Includes the Java Runtime Environment as well as the Java compiler and a variety of tools (version 1.7.0\_79 or later). Can be downloaded from the Oracle website.
 
-3.  *maven* -- Apache Maven is a build system for Java projects (version 3.0.5 or later). It can be downloaded from <https://maven.apache.org/download.cgi>.
+3.  **maven** - Apache Maven is a build system for Java projects (version 3.0.5 or later). It can be downloaded from <https://maven.apache.org/download.cgi>.
 
-4.  *VirtualBox* -- Oracle VirtualBox is a virtual machine manager (version 4.3 or later) and can be downloaded from <https://www.virtualbox.org/wiki/Downloads>. It is needed to run the Data Torrent Sandbox.
+4.  **IDE** (Optional) - If you prefer to use an IDE (Integrated Development Environment) such as *NetBeans*, *Eclipse* or *IntelliJ*, install that as well.
 
-5.  *DataTorrent Sandbox* -- The sandbox can be downloaded from <https://www.datatorrent.com/download>. It is useful for testing simple applications since it contains Apache Hadoop and Data Torrent RTS 3.1.1 pre-installed with a time-limited Enterprise License. If you already installed the RTS Enterprise Edition (evaluation or production license) on a cluster, you can use that setup for deployment and testing instead of the sandbox.
+After installing these tools, make sure that the directories containing the executable files are in your PATH environment variable.
 
-6.  (Optional) If you prefer to use an IDE (Integrated Development Environment) such as *NetBeans*, *Eclipse* or *IntelliJ*, install that as well.
+* **Windows** - Open a console window and enter the command `echo %PATH%` to see the value of the `PATH` variable and verify that the above directories for Java, git, and maven executables are present.  JDK executables like _java_ and _javac_, the directory might be something like `C:\\Program Files\\Java\\jdk1.7.0\_80\\bin`; for _git_ it might be `C:\\Program Files\\Git\\bin`; and for maven it might be `C:\\Users\\user\\Software\\apache-maven-3.3.3\\bin`.  If not, you can change its value clicking on the button at _Control Panel_ &#x21e8; _Advanced System Settings_ &#x21e8; _Advanced tab_ &#x21e8; _Environment Variables_.
+* **Linux and Mac** - Open a console/terminal window and enter the command `echo $PATH` to see the value of the `PATH` variable and verify that the above directories for Java, git, and maven executables are present.  If not, make sure software is downloaded and installed, and optionally PATH reference is added and exported  in a `~/.profile` or `~/.bash_profile`.  For example to add maven located in `/sfw/maven/apache-maven-3.3.3` to PATH add the line: `export PATH=$PATH:/sfw/maven/apache-maven-3.3.3/bin`
 
 
-After installing these tools, make sure that the directories containing the executable files are in your PATH environment; for example, for the JDK executables like _java_ and _javac_, the directory might be something like `C:\\Program Files\\Java\\jdk1.7.0\_80\\bin`; for _git_ it might be `C:\\Program Files\\Git\\bin`; and for maven it might be `C:\\Users\\user\\Software\\apache-maven-3.3.3\\bin`. Open a console window and enter the command:
-
-    echo %PATH%
-
-to see the value of the `PATH` variable and verify that the above directories are present. If not, you can change its value clicking on the button at _Control Panel_ &#x21e8; _Advanced System Settings_ &#x21e8; _Advanced tab_ &#x21e8; _Environment Variables_.
-
-
-Now run the following commands and ensure that the output is something similar to that shown in the table below:
-
+Confirm by running the following commands and comparing with output that show in the table below:
 
 <table>
 <colgroup>
@@ -59,65 +52,52 @@ Now run the following commands and ensure that the output is something similar t
 <tr class="odd">
 <td align="left"><p><tt>mvn --version</tt></p></td>
 <td align="left"><p>Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T06:57:37-05:00)</p>
-<p>Maven home: C:\Users\ram\Software\apache-maven-3.3.3\bin\..</p>
-<p>Java version: 1.7.0_80, vendor: Oracle Corporation</p>
-<p>Java home: C:\Program Files\Java\jdk1.7.0_80\jre</p>
-<p>Default locale: en_US, platform encoding: Cp1252</p>
-<p>OS name: &quot;windows 8&quot;, version: &quot;6.2&quot;, arch: &quot;amd64&quot;, family: &quot;windows&quot;</p></td>
+<p>...</p>
+</td>
 </tr>
 </tbody>
 </table>
 
 
-To install the sandbox, first download it from <https://www.datatorrent.com/download> and import the downloaded file into VirtualBox. Once the import completes, you can select it and click the  Start button to start the sandbox.
-
-
-The sandbox is configured with 6GB RAM; if your development machine has 16GB or more, you can increase the sandbox RAM to 8GB or more using the VirtualBox console. This will yield better performance and support larger applications. Additionally, you can change the network adapter from **NAT** to **Bridged Adapter**; this will allow you to login to the sandbox from your host machine using an _ssh_ tool like **PuTTY** and also to transfer files to and from the host using `pscp` on Windows. Of course all such configuration must be done when when the sandbox is not running.
-
-
-You can choose to develop either directly on the sandbox or on your development machine. The advantage of the former is that most of the tools (e.g. _jdk_, _git_, _maven_) are pre-installed and also the package files created by your project are directly available to the Data Torrent tools such as  **dtManage** and **dtcli**. The disadvantage is that the sandbox is a memory-limited environment so running a memory-hungry tool like a Java IDE on it may starve other applications of memory.
+Creating New Apex Project
+-------------------------------------------------------------------------------
 
+After development tools are configured, you can now use the maven archetype to create a basic Apache Apex project.  **Note:** When executing the commands below, replace `3.3.0-incubating` by [latest available version](http://apex.apache.org/downloads.html) of Apache Apex.
 
-You can now use the maven archetype to create a basic Apache Apex project as follows: Put these lines in a Windows command file called, for example, `newapp.cmd` and run it:
 
-    @echo off
-    @rem Script for creating a new application
-    setlocal
-    mvn archetype:generate ^
-    -DarchetypeRepository=https://www.datatorrent.com/maven/content/repositories/releases ^
-      -DarchetypeGroupId=com.datatorrent ^
-      -DarchetypeArtifactId=apex-app-archetype ^
-      -DarchetypeVersion=3.1.1 ^
-      -DgroupId=com.example ^
-      -Dpackage=com.example.myapexapp ^
-      -DartifactId=myapexapp ^
-      -Dversion=1.0-SNAPSHOT
-    endlocal
+* **Windows** - Create a new Windows command file called `newapp.cmd` by copying the lines below, and execute it.  When you run this file, the properties will be displayed and you will be prompted with `` Y: :``; just press **Enter** to complete the project generation.  The caret (^) at the end of some lines indicates that a continuation line follows. 
 
+        @echo off
+        @rem Script for creating a new application
+        setlocal
+        mvn archetype:generate ^
+         -DarchetypeGroupId=org.apache.apex ^
+         -DarchetypeArtifactId=apex-app-archetype -DarchetypeVersion=3.3.0-incubating ^
+         -DgroupId=com.example -Dpackage=com.example.myapexapp -DartifactId=myapexapp ^
+         -Dversion=1.0-SNAPSHOT
+        endlocal
 
 
-The caret (^) at the end of some lines indicates that a continuation line follows. When you run this file, the properties will be displayed and you will be prompted with `` Y: :``; just press **Enter** to complete the project generation.
+* **Linux** - Execute the lines below in a terminal window.  New project will be created in the curent working directory.  The backslash (\\) at the end of the lines indicates continuation.
 
+        mvn archetype:generate \
+         -DarchetypeGroupId=org.apache.apex \
+         -DarchetypeArtifactId=apex-app-archetype -DarchetypeVersion=3.2.0-incubating \
+         -DgroupId=com.example -Dpackage=com.example.myapexapp -DartifactId=myapexapp \
+         -Dversion=1.0-SNAPSHOT
 
-This command file also exists in the Data Torrent _examples_ repository which you can check out with:
 
-    git clone https://github.com/DataTorrent/examples
-
-You will find the script under `examples\tutorials\topnwords\scripts\newapp.cmd`.
-
-You can also, if you prefer, use an IDE to generate the project as described in Section 3 of [Application Packages](application_packages.md) but use the archetype version 3.1.1 instead of 3.0.0.
-
-
-When the run completes successfully, you should see a new directory named `myapexapp` containing a maven project for building a basic Apache Apex application. It includes 3 source files:**Application.java**,  **RandomNumberGenerator.java** and **ApplicationTest.java**. You can now build the application by stepping into the new directory and running the appropriate maven command:
+When the run completes successfully, you should see a new directory named `myapexapp` containing a maven project for building a basic Apache Apex application. It includes 3 source files:**Application.java**,  **RandomNumberGenerator.java** and **ApplicationTest.java**. You can now build the application by stepping into the new directory and running the maven package command:
 
     cd myapexapp
     mvn clean package -DskipTests
 
-The build should create the application package file `myapexapp\target\myapexapp-1.0-SNAPSHOT.apa`. This file can then be uploaded to the Data Torrent GUI tool on the sandbox (called **dtManage**) and launched  from there. It generates a stream of random numbers and prints them out, each prefixed by the string  `hello world: `.  If you built this package on the host, you can transfer it to the sandbox using the `pscp` tool bundled with **PuTTY** mentioned earlier.
+The build should create the application package file `myapexapp/target/myapexapp-1.0-SNAPSHOT.apa`. This application package can then be used to launch example application via **dtCli**, or other visual management tools.  When running, this application will generate a stream of random numbers and print them out, each prefixed by the string `hello world:`.
 
+Building Apex Demos
+-------------------------------------------------------------------------------
 
-If you want to checkout the Apache Apex source repositories and build them, you can do so by running the script `build-apex.cmd` located in the same place in the examples repository described above. The source repositories contain more substantial demo applications and the associated source code. Alternatively, if you do not want to use the script, you can follow these simple manual steps:
-
+If you want to see more substantial Apex demo applications and the associated source code, you can follow these simple steps to check out and build them.
 
 1.  Check out the source code repositories:
 
@@ -126,26 +106,23 @@ If you want to checkout the Apache Apex source repositories and build them, you
 
 2.  Switch to the appropriate release branch and build each repository:
 
-        pushd incubator-apex-core
-        git checkout release-3.1
+        cd incubator-apex-core
         mvn clean install -DskipTests
-        popd
-        pushd incubator-apex-malhar
-        git checkout release-3.1
+
+        cd incubator-apex-malhar
         mvn clean install -DskipTests
-        popd
+
 
 The `install` argument to the `mvn` command installs resources from each project to your local maven repository (typically `.m2/repository` under your home directory), and **not** to the system directories, so Administrator privileges are not required. The  `-DskipTests` argument skips running unit tests since they take a long time. If this is a first-time installation, it might take several minutes to complete because maven will download a number of associated plugins.
 
-After the build completes, you should see the demo application package files in the target directory under each demo subdirectory in `incubator-apex-malhar\demos\`.
+After the build completes, you should see the demo application package files in the target directory under each demo subdirectory in `incubator-apex-malhar/demos`.
+
 
-Linux
-------------------
 
-Most of the instructions for Linux (and other Unix-like systems) are similar to those for Windows described above, so we will just note the differences.
+Sandbox
+-------------------------------------------------------------------------------
 
+To jump start development with an Apache Hadoop single node cluster, [DataTorrent Sandbox](https://www.datatorrent.com/download) powered by VirtualBox is available on Windows, Linux, or Mac platforms.  The sandbox is configured by default to run with 6GB RAM; if your development machine has 16GB or more, you can increase the sandbox RAM to 8GB or more using the VirtualBox console.  This will yield better performance and support larger applications.  The advantage of developing in the sandbox is that most of the tools (e.g. _jdk_, _git_, _maven_), Hadoop YARN and HDFS, and a distribution of Apache Apex and DataTorrent RTS are pre-installed.  The disadvantage is that the sandbox is a memory-limited environment, and requires settings changes and restarts to adjust memory available for development and testing.
 
-The pre-requisites (such as _git_, _maven_, etc.) are the same as for Windows described above; please run the commands in the table and ensure that appropriate versions are present in your PATH environment variable (the command to display that variable is: `echo $PATH`).
 
 
-The maven archetype command is the same except that continuation lines use a backslash (``\``) instead of caret (``^``); the script for it is available in the same location and is named `newapp` (without the `.cmd` extension). The script to checkout and build the Apache Apex repositories is named `build-apex`.

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/cfdacdf2/docs/apex_malhar.md
----------------------------------------------------------------------
diff --git a/docs/apex_malhar.md b/docs/apex_malhar.md
index ef2e371..45dee76 100644
--- a/docs/apex_malhar.md
+++ b/docs/apex_malhar.md
@@ -1,19 +1,19 @@
 Apache Apex Malhar
 ================================================================================
 
-Apache Apex Malhar is an open source operator and codec library that can be used with the Apache Apex platform to build real-time streaming applications.  As part of enabling enterprises extract value quickly, Malhar operators help get data in, analyze it in real-time and get data out of Hadoop in real-time with no paradigm limitations.  In addition to the operators, the library contains a number of demos applications, demonstrating operator features and capabilities.
+Apache Apex Malhar is an open source operator and codec library that can be used with the [Apache Apex](http://apex.apache.org/) platform to build real-time streaming applications.  Enabling users to extract value quickly, Malhar operators help get data in, analyze it in real-time, and get data out of Hadoop.  In addition to the operators, the library contains a number of demos applications, demonstrating operator features and capabilities.  To see the full list of available operators and related documentation, visit [Apex Malhar on Github](https://github.com/apache/incubator-apex-malhar)
 
-![MalharDiagram](images/MalharOperatorOverview.png)
+![MalharDiagram](images/malhar-operators.png)
 
 # Capabilities common across Malhar operators
 
-For most streaming platforms, connectors are afterthoughts and often end up being simple ‘bolt-ons’ to the platform. As a result they often cause performance issues or data loss when put through failure scenarios and scalability requirements. Malhar operators do not face these issues as they were designed to be integral parts of apex*.md RTS. Hence, they have following core streaming runtime capabilities
+For most streaming platforms, connectors are afterthoughts and often end up being simple ‘bolt-ons’ to the platform. As a result they often cause performance issues or data loss when put through failure scenarios and scalability requirements. Malhar operators do not face these issues as they were designed to be integral parts of Apex. Hence, they have following core streaming runtime capabilities
 
-1.  **Fault tolerance** – Apache Apex Malhar operators where applicable have fault tolerance built in. They use the checkpoint capability provided by the framework to ensure that there is no data loss under ANY failure scenario.
-2.  **Processing guarantees** – Malhar operators where applicable provide out of the box support for ALL three processing guarantees – exactly once, at-least once & at-most once WITHOUT requiring the user to write any additional code.  Some operators like MQTT operator deal with source systems that cant track processed data and hence need the operators to keep track of the data. Malhar has support for a generic operator that uses alternate storage like HDFS to facilitate this. Finally for databases that support transactions or support any sort of atomic batch operations Malhar operators can do exactly once down to the tuple level.
+1.  **Fault tolerance** – Malhar operators where applicable have fault tolerance built in. They use the checkpoint capability provided by the framework to ensure that there is no data loss under ANY failure scenario.
+2.  **Processing guarantees** – Malhar operators where applicable provide out of the box support for ALL three processing guarantees – exactly once, at-least once, and at-most once WITHOUT requiring the user to write any additional code.  Some operators, like MQTT operator, deal with source systems that can not track processed data and hence need the operators to keep track of the data.  Malhar has support for a generic operator that uses alternate storage like HDFS to facilitate this.  Finally for databases that support transactions or support any sort of atomic batch operations Malhar operators can do exactly once down to the tuple level.
 3.  **Dynamic updates** – Based on changing business conditions you often have to tweak several parameters used by the operators in your streaming application without incurring any application downtime. You can also change properties of a Malhar operator at runtime without having to bring down the application.
 4.  **Ease of extensibility** – Malhar operators are based on templates that are easy to extend.
-5.  **Partitioning support** – In streaming applications the input data stream often needs to be partitioned based on the contents of the stream. Also for operators that ingest data from external systems partitioning needs to be done based on the capabilities of the external system. E.g. With the Kafka or Flume operator, the operator can automatically scale up or down based on the changes in the number of Kafka partitions or Flume channels
+5.  **Partitioning support** – In streaming applications the input data stream often needs to be partitioned based on the contents of the stream. Also for operators that ingest data from external systems partitioning needs to be done based on the capabilities of the external system.  For example with Kafka, the operator can automatically scale up or down based on the changes in the number of Kafka partitions.
 
 # Operator Library Overview
 
@@ -21,45 +21,39 @@ For most streaming platforms, connectors are afterthoughts and often end up bein
 
 Below is a summary of the various sub categories of input and output operators. Input operators also have a corresponding output operator
 
-*   **File Systems** – Most streaming analytics use cases we have seen require the data to be stored in HDFS or perhaps S3 if the application is running in AWS. Also, customers often need to re-run their streaming analytical applications against historical data or consume data from upstream processes that are perhaps writing to some NFS share. Hence, it’s not just enough to be able to save data to various file systems. You also have to be able to read data from them. RTS supports input & output operators for HDFS, S3, NFS & Local Files
-*   **Flume** – NOTE: Flume operator is not yet part of Malhar
+*   **File Systems** – Most streaming analytics use cases require the data to be stored in HDFS or perhaps S3 if the application is running in AWS.  Users often need to re-run their streaming analytical applications against historical data or consume data from upstream processes that are perhaps writing to some NFS share.  Apex supports input & output operators for HDFS, S3, NFS & Local Files.  There are also File Splitter and Block Reader operators, which can accelecate processing of large files by splitting and paralellizing the work across non-overlapping sets of file blocks.
+*   **Relational Databases** – Most stream processing use cases require some reference data lookups to enrich, tag or filter streaming data. There is also a need to save results of the streaming analytical computation to a database so an operational dashboard can see them. Apex supports a JDBC operator so you can read/write data from any JDBC compliant RDBMS like Oracle, MySQL, Sqlite, etc.
+*   **NoSQL Databases** – NoSQL key-value pair databases like Cassandra & HBase are a common part of streaming analytics application architectures to lookup reference data or store results.  Malhar has operators for HBase, Cassandra, Accumulo, Aerospike, MongoDB, and CouchDB.
+*   **Messaging Systems** – Kafka, JMS, and similar systems are the workhorses of messaging infrastructure in most enterprises.  Malhar has a robust, industry-tested set of operators to read and write Kafka, JMS, ZeroMQ, and RabbitMQ messages.
+*   **Notification Systems** – Malhar includes an operator for sending notifications via SMTP.
+*   **In-memory Databases & Caching platforms** - Some streaming use cases need instantaneous access to shared state across the application. Caching platforms and in-memory databases serve this purpose really well. To support these use cases, Malhar has operators for memcached and Redis.
+*   **Social Media** - Malhar includes an operator to connect to the popular Twitter stream fire hose.
+*   **Protocols** - Malhar provides connectors that can communicate in HTTP, RSS, Socket, WebSocket, FTP, and MQTT.
 
-Many customers have existing Flume deployments that are being used to aggregate log data from variety of sources. However Flume does not allow analytics on the log data on the fly. The Flume input/output operator enables RTS to consume data from flume and analyze it in real-time before being persisted.
+## Parsers
 
-*   **Relational databases** – Most stream processing use cases require some reference data lookups to enrich, tag or filter streaming data. There is also a need to save results of the streaming analytical computation to a database so an operational dashboard can see them. RTS supports a JDBC operator so you can read/write data from any JDBC compliant RDBMS like Oracle, MySQL etc.
-*   **NoSQL databases** –NoSQL key-value pair databases like Cassandra & HBase are becoming a common part of streaming analytics application architectures to lookup reference data or store results. Malhar has operators for HBase, Cassandra, Accumulo (common with govt. & healthcare companies) MongoDB & CouchDB.
-*   **Messaging systems** – JMS brokers have been the workhorses of messaging infrastructure in most enterprises. Also Kafka is fast coming up in almost every customer we talk to. Malhar has operators to read/write to Kafka, any JMS implementation, ZeroMQ & RabbitMQ.
-*   **Notification systems** – Almost every streaming analytics application has some notification requirements that are tied to a business condition being triggered. Malhar supports sending notifications via SMTP & SNMP. It also has an alert escalation mechanism built in so users don’t get spammed by notifications (a common drawback in most streaming platforms)
-*   **In-memory Databases & Caching platforms** - Some streaming use cases need instantaneous access to shared state across the application. Caching platforms and in-memory databases serve this purpose really well. To support these use cases, Malhar has operators for memcached & Redis
-*   **Protocols** - Streaming use cases driven by machine-to-machine communication have one thing in common – there is no standard dominant protocol being used for communication. Malhar currently has support for MQTT. It is one of the more commonly, adopted protocols we see in the IoT space. Malhar also provides connectors that can directly talk to HTTP, RSS, Socket, WebSocket & FTP sources
+There are many industry vertical specific data formats that a streaming application developer might need to parse. Often there are existing parsers available for these that can be directly plugged into an Apache Apex application. For example in the Telco space, a Java based CDR parser can be directly plugged into Apache Apex operator. To further simplify development experience, Malhar also provides some operators for parsing common formats like XML (DOM & SAX), JSON (flat map converter), Apache log files, syslog, etc.
 
+## Stream manipulation
 
+Streaming data inevitably needs processing to clean, filter, tag, summarize, etc. The goal of Malhar is to enable the application developer to focus on WHAT needs to be done to the stream to get it in the right format and not worry about the HOW.  Malhar has several operators to perform the common stream manipulation actions like – GroupBy, Join, Distinct/Unique, Limit, OrderBy, Split, Sample, Inner join, Outer join, Select, Update etc.
 
 ## Compute
 
-One of the most important promises of a streaming analytics platform like Apache Apex is the ability to do analytics in real-time. However delivering on the promise becomes really difficult when the platform does not provide out of the box operators to support variety of common compute functions as the user then has to worry about making these scalable, fault tolerant etc. Malhar takes this responsibility away from the application developer by providing a huge variety of out of the box computational operators. The application developer can thus focus on the analysis.
+One of the most important promises of a streaming analytics platform like Apache Apex is the ability to do analytics in real-time. However delivering on the promise becomes really difficult when the platform does not provide out of the box operators to support variety of common compute functions as the user then has to worry about making these scalable, fault tolerant, stateful, etc.  Malhar takes this responsibility away from the application developer by providing a variety of out of the box computational operators.
 
 Below is just a snapshot of the compute operators available in Malhar
 
-*   Statistics & Math - Provide various mathematical and statistical computations over application defined time windows.
-*   Filtering & pattern matching
-*   Machine learning & Algorithms
-*   Real-time model scoring is a very common use case for stream processing platforms. &nbsp;Malhar allows users to invoke their R models from streaming applications
-*   Sorting, Maps, Frequency, TopN, BottomN, Random Generator etc.
-
-
-## Query & Script invocation
-
-Many streaming use cases are legacy implementations that need to be ported over. This often requires re-use some of the existing investments and code that perhaps would be really hard to re-write. With this in mind, Malhar supports invoking external scripts and queries as part of the streaming application using operators for invoking SQL query, Shell script, Ruby, Jython, and JavaScript etc.
-
-## Parsers
-
-There are many industry vertical specific data formats that a streaming application developer might need to parse. Often there are existing parsers available for these that can be directly plugged into an Apache Apex application. For example in the Telco space, a Java based CDR parser can be directly plugged into Apache Apex operator. To further simplify development experience, Malhar also provides some operators for parsing common formats like XML (DOM & SAX), JSON (flat map converter), Apache log files, syslog, etc.
-
-## Stream manipulation
+*   Statistics and math - Various mathematical and statistical computations over application defined time windows.
+*   Filtering and pattern matching
+*   Sorting, maps, frequency, TopN, BottomN
+*   Random data generators
 
-Streaming data aka ‘stream’ is raw data that inevitably needs processing to clean, filter, tag, summarize etc. The goal of Malhar is to enable the application developer to focus on ‘WHAT’ needs to be done to the stream to get it in the right format and not worry about the ‘HOW’. Hence, Malhar has several operators to perform the common stream manipulation actions like – DeDupe, GroupBy, Join, Distinct/Unique, Limit, OrderBy, Split, Sample, Inner join, Outer join, Select, Update etc.
+## Languages Support
 
-## Social Media
+Migrating to a new platform often requires re-use of the existing code that would be difficult or time-consuming to re-write.  With this in mind, Malhar supports invocation of code written in other languages by wrapping them in one of the library operators, and allows execution of software written in:
 
-Malhar includes an operator to connect to the popular Twitter stream fire hose.
+* JavaScript
+* Python
+* R
+* Ruby
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/cfdacdf2/docs/application_development.md
----------------------------------------------------------------------
diff --git a/docs/application_development.md b/docs/application_development.md
index a76ad8a..c5c9075 100644
--- a/docs/application_development.md
+++ b/docs/application_development.md
@@ -1,50 +1,16 @@
 Application Developer Guide
 ===========================
 
-Real-time big data processing is not only important but has become
-critical for businesses which depend on accurate and timely analysis of
-their business data. A few businesses have yielded to very expensive
-solutions like building an in-house, real-time analytics infrastructure
-supported by an internal development team, or buying expensive
-proprietary software. A large number of businesses are dealing with the
-requirement just by trying to make Hadoop do their batch jobs in smaller
-iterations. Over the last few years, Hadoop has become ubiquitous in the
-big data processing space, replacing expensive proprietary hardware and
-software solutions for massive data processing with very cost-effective,
-fault-tolerant, open-sourced, and commodity-hardware-based solutions.
-While Hadoop has been a game changer for companies, it is primarily a
-batch-oriented system, and does not yet have a viable option for
-real-time data processing.  Most companies with real-time data
-processing end up having to build customized solutions in addition to
-their Hadoop infrastructure.
-
- 
-
-The DataTorrent platform is designed to process massive amounts of
-real-time events natively in Hadoop. This can be event ingestion,
-processing, and aggregation for real-time data analytics, or can be
-real-time business logic decisioning such as cell tower load balancing,
-real-time ads bidding, or fraud detection.  The platform has the ability
-to repair itself in real-time (without data loss) if hardware fails, and
-adapt to changes in load by adding and removing computing resources
-automatically.
-
-
-
-DataTorrent is a native Hadoop application. It runs as a YARN
-(Hadoop 2.x) application and leverages Hadoop as a distributed operating
-system. All the basic distributed operating system capabilities of
-Hadoop like resource allocation (Resource Manager, distributed file system (HDFS),
-multi-tenancy, security, fault-tolerance, scalability, etc.
-are supported natively in all streaming applications.  Just as Hadoop
-for map-reduce handles all the details of the application allowing you
-to only focus on writing the application (the mapper and reducer
-functions), the platform handles all the details of streaming execution,
-allowing you to only focus on your business logic. Using the platform
-removes the need to maintain separate clusters for real-time
-applications.
-
-
+The Apex platform is designed to process massive amounts of
+real-time events natively in Hadoop.  It runs as a YARN (Hadoop 2.x) 
+application and leverages Hadoop as a distributed operating
+system.  All the basic distributed operating system capabilities of
+Hadoop like resource management (YARN), distributed file system (HDFS),
+multi-tenancy, security, fault-tolerance, and scalability are supported natively 
+in all the Apex applications.  The platform handles all the details of the application 
+execution, including dynamic scaling, state checkpointing and recovery, event 
+processing guarantees, etc. allowing you to focus on writing your application logic without
+mixing operational and functional concerns.
 
 In the platform, building a streaming application can be extremely
 easy and intuitive.  The application is represented as a Directed
@@ -56,25 +22,24 @@ processing is not available in the Operator Library, one can easily
 write a custom operator. We refer those interested in creating their own
 operators to the [Operator Development Guide](operator_development.md).
 
+
 Running A Test Application
 =======================================
 
-This chapter will help you with a quick start on running an
-application. If you are starting with the platform for the first time,
-it would be informative to open an existing application and see it run.
-Do the following steps to run the PI demo, which computes the value of
-PI  in a simple
-manner:
+If you are starting with the Apex platform for the first time,
+it can be informative to launch an existing application and see it run.
+One of the simplest examples provided in [Apex Malhar](apex_malhar.md) is a Pi demo application,
+which computes the value of PI using random numbers.  After [setting up development environment](apex_development_setup.md)
+Pi demo can be launched as follows:
 
-1.  Open up platform files in your IDE (for example NetBeans, or Eclipse)
-2.  Open Demos project
-3.  Open Test Packages and run ApplicationTest.java in pi package
-4.  See the results in your system console
+1.  Open up Apex Malhar files in your IDE (for example Eclipse, IntelliJ, NetBeans, etc)
+2.  Navigate to `demos/pi/src/test/java/com/datatorrent/demos/ApplicationTest.java`
+3.  Run the test for ApplicationTest.java
+4.  View the output in system console
 
 
-
-Congratulations, you just ran your first real-time streaming demo
-:) This demo is very simple and has four operators. The first operator
+Congratulations, you just ran your first real-time streaming demo :) 
+This demo is very simple and has four operators. The first operator
 emits random integers between 0 to 30, 000. The second operator receives
 these coefficients and emits a hashmap with x and y values each time it
 receives two values. The third operator takes these values and computes
@@ -119,6 +84,7 @@ platform. In the remaining part of this document we will go through
 details needed for you to develop and run streaming applications in
 Malhar.
 
+
 Test Application: Yahoo! Finance Quotes
 ----------------------------------------------------
 
@@ -622,7 +588,7 @@ attribute APPLICATION_WINDOW_COUNT.
 In the rest of this chapter we will run through the process of
 running this application. We assume that  you are familiar with details
 of your Hadoop infrastructure. For installation
-details please refer to the [Installation Guide](installation.md).
+details please refer to the [Installation Guide](http://docs.datatorrent.com/installation/).
 
 
 Running a Test Application
@@ -1449,7 +1415,7 @@ not impact functionality of the operator. Users can change certain
 attributes in runtime. Users cannot add attributes to operators; they
 are pre-defined by the platform. They are interpreted by the platform
 and thus cannot be defined in user created code (like properties).
-Details of attributes are covered in  [Configuration Guide](configuration.md).
+Details of attributes are covered in  [Configuration Guide](http://docs.datatorrent.com/configuration/).
 
 ### Operator State
 
@@ -1857,10 +1823,7 @@ Hadoop is a multi-tenant distributed operating system. Security is
 an intrinsic element of multi-tenancy as without it a cluster cannot be
 reasonably be shared among enterprise applications. Streaming
 applications follow all multi-tenancy security models used in Hadoop as
-they are native Hadoop applications. For details refer to the
-[Operation and Installation
-Guide](https://www.datatorrent.com/docs/guides/OperationandInstallationGuide.html)
-.
+they are native Hadoop applications.
 
 Security
 ---------------------
@@ -2824,7 +2787,7 @@ is not yet available.
 
 
 
-9: Dynamic Application Modifications
+Dynamic Application Modifications
 =================================================
 
 Dynamic application modifications are being worked on and most of
@@ -2872,7 +2835,7 @@ Dynamic modifications to applications are foundational part of the
 platform. They enable users to build layers over the applications. Users
 can also save all the changes done since the application launch, and
 therefore predictably get the application to its current state. For
-details refer to  [Configuration Guide](configuration.md)
+details refer to  [Configuration Guide](http://docs.datatorrent.com/configuration/)
 .
 
 
@@ -2881,54 +2844,11 @@ details refer to  [Configuration Guide](configuration.md)
 
 
 
-
-User Interface
-===========================
-
-The platform provides a rich user interface. This includes tools
-to monitor the application system metrics (throughput, latency, resource
-utilization, etc.); dashboards for application data, replay, errors; and
-a Developer studio for application creation, launch etc. For details
-refer to  [UI Console Guide](dtmanage.md).
-
-
-
 Demos
 ==================
 
-In this section we list some of the demos that come packaged with
-installer. The source code for the demos is available in the open-source
+The source code for the demos is available in the open-source
 [Apache Apex-Malhar repository](https://github.com/apache/incubator-apex-malhar).
 All of these do computations in real-time. Developers are encouraged to
 review them as they use various features of the platform and provide an
-opportunity for quick learning.
-
-1.  Computation of PI:
-    Computes PI by generating a random location on X-Y plane and
-    measuring how often it lies within the unit circle centered
-    at (0,0).
-2.  Yahoo! Finance quote computation:
-    Computes ticker quote, 1-day chart (per min), and simple moving
-    averages (per 5 min).
-3.  Echoserver Reads messages from a
-    network connection and echoes them back out.
-4.  Twitter top N tweeted urls: Computes
-    top N tweeted urls over last 5 minutes
-5.  Twitter trending hashtags: Computes
-    the top Twitter Hashtags over the last 5 minutes
-6.  Twitter top N frequent words:
-    Computes top N frequent words in a sliding window
-7.  Word count: Computes word count for
-    all words within a large file
-8.  Mobile location tracker: Tracks
-    100,000 cell phones within an area code moving at car speed (jumping
-    cell phone towers every 1-5 seconds).
-9.  Frauddetect: Analyzes a stream of
-    credit card merchant transactions.
-10. Mroperator:Contains several
-    map-reduce applications.
-11. R: Analyzes a synthetic stream of
-    eruption event data for the Old Faithful
-    geyser (https://en.wikipedia.org/wiki/Old_Faithful).
-12. Machinedata: Analyzes a synthetic
-    stream of events to determine health of a machine.  
+opportunity for quick learning.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/cfdacdf2/docs/application_packages.md
----------------------------------------------------------------------
diff --git a/docs/application_packages.md b/docs/application_packages.md
index 521779a..06c2980 100644
--- a/docs/application_packages.md
+++ b/docs/application_packages.md
@@ -107,7 +107,7 @@ other IDEs, like Eclipse or IntelliJ, is similar.
 # Writing Your Own App Package
 
 
-Please refer to the [Creating Apps](create.md) on the basics on how to write an Apache Apex application.  In your AppPackage project, you can add custom operators (refer to [Operator Development Guide](https://www.datatorrent.com/docs/guides/OperatorDeveloperGuide.html)), project dependencies, default and required configuration properties, pre-set configurations and other metadata.
+Please refer to the [Creating Apps](http://docs.datatorrent.com/create/) on the basics on how to write an Apache Apex application.  In your AppPackage project, you can add custom operators (refer to [Operator Development Guide](operator_development.md), project dependencies, default and required configuration properties, pre-set configurations and other metadata.
 
 ## Adding (and removing) project dependencies
 
@@ -398,8 +398,6 @@ property:
 
         dt.attr.APPLICATION_NAME
 
-There are also other properties that can be set.  For details on
-properties, refer to the [Operation and Installation Guide](https://www.datatorrent.com/docs/guides/OperationandInstallationGuide.html).
 
 In this example, property some_name_1 is a required property which
 must be set at launch time, or it must be set by a pre-set configuration
@@ -623,12 +621,12 @@ Here is an example of launching an application through curl:
  lications/MyFirstApplication/launch
 ```
 
-Please refer to the [Gateway API reference](https://www.google.com/url?q=https://www.datatorrent.com/docs/guides/DTGatewayAPISpecification.html&sa=D&usg=AFQjCNEWfN7-e7fd6MoWZjmJUE3GW7UwdQ) for the complete specification of the REST API.
+Please refer to the [Gateway API](http://docs.datatorrent.com/dtgateway_api/) for the complete specification of the REST API.
 
 # Examining and Launching Application Packages Through Apex CLI
 
 If you are working with Application Packages in the local filesystem and
-do not want to deal with dtGateway, you can use the Apex Command Line Interface (dtcli).  Please refer to the [Gateway API](dtgateway_api.md)
+do not want to deal with dtGateway, you can use the Apex Command Line Interface (dtcli).  Please refer to the [Gateway API](http://docs.datatorrent.com/dtgateway_api/)
 to see samples for these commands.
 
 ## Getting Application Package Meta Information

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/cfdacdf2/docs/autometrics.md
----------------------------------------------------------------------
diff --git a/docs/autometrics.md b/docs/autometrics.md
index f6000e8..c534fb2 100644
--- a/docs/autometrics.md
+++ b/docs/autometrics.md
@@ -123,6 +123,13 @@ An instance of above aggregator can be specified as the `METRIC_AGGREGATOR` for
 ```
 
 # Retrieving AutoMetrics
+
+There are two options for retrieving the AutoMetrics:
+
+* Throught DataTorrent Gateway REST API
+* Through REST service on the port of the running STRAM
+
+
 The Gateway REST API provides a way to retrieve the latest AutoMetrics for each logical operator.  For example:
 
 ```
@@ -167,145 +174,4 @@ GET /ws/v2/applications/{appid}/logicalPlan/operators/{opName}
 }
 ```
 
-However, just like AutoMetrics, the Gateway only provides the latest metrics.  For historical metrics, we will need the help of App Data Tracker.
-
-# App Data Tracker
-As discussed above, STRAM aggregates the AutoMetrics from physical operators (partitions) to something that makes sense in one logical operator.  It pushes the aggregated AutoMetrics values using Websocket to the Gateway at every second along with system metrics for each operator.  Gateway relays the information to an application called App Data Tracker.  It is another Apex application that runs in the background and further aggregates the incoming values by time bucket and stores the values in HDHT.  It also allows the outside to retrieve the aggregated AutoMetrics and system metrics through websocket interface.
-
-![AppDataTracker](images/autometrics/adt.png)
-
-App Data Tracker is enabled by having these properties in dt-site.xml:
-
-```xml
-<property>
-  <name>dt.appDataTracker.enable</name>
-  <value>true</value>
-</property>
-<property>
-  <name>dt.appDataTracker.transport</name>
-  <value>builtin:AppDataTrackerFeed</value>
-</property>
-<property>
-  <name>dt.attr.METRICS_TRANSPORT</name>
-  <value>builtin:AppDataTrackerFeed</value>
-</property>
-```
-
-All the applications launched after the App Data Tracker is enabled will have metrics sent to it.
-
-**Note**: The App Data Tracker will be shown running in dtManage as a “system app”.  It will show up if the “show system apps” button is pressed.
-
-By default, the time buckets App Data Tracker aggregates upon are one minute, one hour and one day.  It can be overridden by changing the operator attribute `METRICS_DIMENSIONS_SCHEME`.
-
-Also by default, the app data tracker performs all these aggregations: SUM, MIN, MAX, AVG, COUNT, FIRST, LAST on all number metrics.  You can also override by changing the same operator attribute `METRICS_DIMENSIONS_SCHEME`, provided the custom aggregator is known to the App Data Tracker.  (See next section)
-
-# Custom Aggregator in App Data Tracker
-Custom aggregators allow you to do your own custom computation on statistics generated by any of your applications. In order to implement a Custom aggregator you have to do two things:
-
-1. Combining new inputs with the current aggregation
-2. Combining two aggregations together into one aggregation
-
-Let’s consider the case where we want to perform the following rolling average:
-
-Y_n = ½ * X_n + ½ * X_n-1 + ¼ * X_n-2 + ⅛ * X_n-3 +...
-
-This aggregation could be performed by the following Custom Aggregator:
-
-```java
-@Name("IIRAVG")
-public class AggregatorIIRAVG extends AbstractIncrementalAggregator
-{
-  ...
-
-  private void aggregateHelper(DimensionsEvent dest, DimensionsEvent src)
-  {
-    double[] destVals = dest.getAggregates().getFieldsDouble();
-    double[] srcVals = src.getAggregates().getFieldsDouble();
-
-    for (int index = 0; index < destLongs.length; index++) {
-      destVals[index] = .5 * destVals[index] + .5 * srcVals[index];
-    }
-  }
-
-  @Override
-  public void aggregate(Aggregate dest, InputEvent src)
-  {
-    //Aggregate a current aggregation with a new input
-    aggregateHelper(dest, src);
-  }
-
-  @Override
-  public void aggregate(Aggregate destAgg, Aggregate srcAgg)
-  {
-    //Combine two existing aggregations together
-    aggregateHelper(destAgg, srcAgg);
-  }
-}
-```
-
-## Discovery of Custom Aggregators
-AppDataTracker searches for custom aggregator jars under the following directories statically before launching:
-
-1. {dt\_installation\_dir}/plugin/aggregators
-2. {user\_home\_dir}/.dt/plugin/aggregators
-
-It uses reflection to find all the classes that extend from `IncrementalAggregator` and `OTFAggregator` in these jars and registers them with the name provided by `@Name` annotation (or class name when `@Name` is absent).
-
-# Using `METRICS_DIMENSIONS_SCHEME`
-
-Here is a sample code snippet on how you can make use of `METRICS_DIMENSIONS_SCHEME` to set your own time buckets and your own set of aggregators for certain `AutoMetric`s performed by the App Data Tracker in your application.
-
-```java
-  @Override
-  public void populateDAG(DAG dag, Configuration configuration)
-  {
-    ...
-    LineReceiver lineReceiver = dag.addOperator("LineReceiver", new LineReceiver());
-    ...
-    AutoMetric.DimensionsScheme dimensionsScheme = new AutoMetric.DimensionsScheme()
-    {
-      String[] timeBuckets = new String[] { "1s", "1m", "1h" };
-      String[] lengthAggregators = new String[] { "IIRAVG", "SUM" };
-      String[] countAggregators = new String[] { "SUM" };
-
-      /* Setting the aggregation time bucket to be one second, one minute and one hour */
-      @Override
-      public String[] getTimeBuckets()
-      {
-        return timeBuckets;
-      }
-
-      @Override
-      public String[] getDimensionAggregationsFor(String logicalMetricName)
-      {
-        if ("length".equals(logicalMetricName)) {
-          return lengthAggregators;
-        } else if ("count".equals(logicalMetricName)) {
-          return countAggregators;
-        } else {
-          return null; // use default
-        }
-      }
-    };
-
-    dag.setAttribute(lineReceiver, OperatorContext.METRICS_DIMENSIONS_SCHEME, dimensionsScheme);
-    ...
-  }
-```
-
-
-# Dashboards
-With App Data Tracker enabled, you can visualize the AutoMetrics and system metrics in the Dashboards within dtManage.   Refer back to the diagram in the App Data Tracker section, dtGateway relays queries and query results to and from the App Data Tracker.  In this way, dtManage sends queries and receives results from the App Data Tracker via dtGateway and uses the results to let the user visualize the data.
-
-Click on the visualize button in dtManage's application page.
-
-![AppDataTracker](images/autometrics/visualize.png)
-
-You will see the dashboard for the AutoMetrics and the system metrics.
-
-![AppDataTracker](images/autometrics/dashboard.png)
-
-The left widget shows the AutoMetrics of `line` and `count` for the LineReceiver operator.  The right widget shows the system metrics.
-
-The Dashboards have some simple builtin widgets to visualize the data.  Line charts and bar charts are some examples.
-Users will be able to implement their own widgets to visualize their data.
+However, just like AutoMetrics, the Gateway only provides the latest metrics.  For historical metrics, we will need the help of [App Data Tracker](http://docs.datatorrent.com/autometrics/#app-data-tracker).
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/cfdacdf2/docs/dtcli.md
----------------------------------------------------------------------
diff --git a/docs/dtcli.md b/docs/dtcli.md
index 813a27f..8cf11e6 100644
--- a/docs/dtcli.md
+++ b/docs/dtcli.md
@@ -1,12 +1,7 @@
 Apache Apex Command Line Interface
 ================================================================================
 
-dtCli, the Apache Apex command line interface, can be used to launch, monitor, and manage
-Apache Apex applications.  dtCli is a wrapper around the [REST API](dtgateway_api.md) provided by dtGatway, and
-provides a developer friendly way of interacting with Apache Apex platform. The CLI enables a much higher level of feature set by
-hiding deep details of REST API.  Another advantage of dtCli is to provide scope, by connecting and executing commands in a context
-of specific application.  dtCli enables easy integration with existing enterprise toolset for automated application monitoring
-and management.  Currently the following high level tasks are supported.
+dtCli, the Apache Apex command line interface, can be used to launch, monitor, and manage Apache Apex applications.  It provides a developer friendly way of interacting with Apache Apex platform.  Another advantage of dtCli is to provide scope, by connecting and executing commands in a context of specific application.  dtCli enables easy integration with existing enterprise toolset for automated application monitoring and management.  Currently the following high level tasks are supported.
 
 -   Launch or kill applications
 -   View system metrics including load, throughput, latency, etc.
@@ -19,7 +14,7 @@ and management.  Currently the following high level tasks are supported.
 
 ## dtcli Commands
 
-dtCli can be launched by running following command on the same machine where dtGatway was installed
+dtCli can be launched by running following command
 
     dtcli
 

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/cfdacdf2/docs/favicon.ico
----------------------------------------------------------------------
diff --git a/docs/favicon.ico b/docs/favicon.ico
new file mode 100644
index 0000000..c0b3dae
Binary files /dev/null and b/docs/favicon.ico differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/cfdacdf2/docs/images/MalharOperatorOverview.png
----------------------------------------------------------------------
diff --git a/docs/images/MalharOperatorOverview.png b/docs/images/MalharOperatorOverview.png
deleted file mode 100644
index 40bee4a..0000000
Binary files a/docs/images/MalharOperatorOverview.png and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/cfdacdf2/docs/index.md
----------------------------------------------------------------------
diff --git a/docs/index.md b/docs/index.md
new file mode 100644
index 0000000..6a78abf
--- /dev/null
+++ b/docs/index.md
@@ -0,0 +1,20 @@
+Apache Apex (Incubating)
+================================================================================
+
+Apex is a Hadoop YARN native big data processing platform, enabling real time stream as well as batch processing for your big data.  Apex provides the following benefits:
+
+* High scalability and performance
+* Fault tolerance and state management
+* Hadoop-native YARN & HDFS implementation
+* Event processing guarantees
+* Separation of functional and operational concerns
+* Simple API supports generic Java code
+
+Platform has been demonstated to scale linearly across Hadoop clusters under extreme loads of billions of events per second.  Hardware and process failures are quickly recovered with HDFS-backed checkpointing and automatic operator recovery, preserving application state and resuming execution in seconds.  Functional and operational specifications are separated.  Apex provides a simple API, which enables users to write generic, reusable code.  The code is dropped in as-is and platform automatically handles the various operational concerns, such as state management, fault tolerance, scalability, security, metrics, etc.  This frees users to focus on functional development, and lets platform provide operability support.
+
+The core Apex platform is supplemented by Malhar, a library of connector and logic functions, enabling rapid application development.  These operators and modules provide access to HDFS, S3, NFS, FTP, and other file systems; Kafka, ActiveMQ, RabbitMQ, JMS, and other message systems; MySql, Cassandra, MongoDB, Redis, HBase, CouchDB, generic JDBC, and other database connectors. The Malhar library also includes a host of other common business logic patterns that help users to significantly reduce the time it takes to go into production.  Ease of integration with all other big data technologies is one of the primary missions of Malhar.
+
+
+For additional information visit [Apache Apex (incubating)](http://apex.incubator.apache.org/).
+
+[![](favicon.ico)](http://apex.incubator.apache.org/)

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/cfdacdf2/docs/operator_development.md
----------------------------------------------------------------------
diff --git a/docs/operator_development.md b/docs/operator_development.md
index f502725..85ebab5 100644
--- a/docs/operator_development.md
+++ b/docs/operator_development.md
@@ -287,7 +287,7 @@ Code
 
 The source code for the tutorial can be found here:
 
-[https://github.com/DataTorrent/examples/tree/master/tutorials/operatorTutorial](https://www.google.com/url?q=https://github.com/DataTorrent/examples/tree/master/tutorials/operatorTutorial&sa=D&usg=AFQjCNHAAgSpNprHJVvy9GSjdlD1uwU7jw)
+[https://github.com/DataTorrent/examples/tree/master/tutorials/operatorTutorial](https://github.com/DataTorrent/examples/tree/master/tutorials/operatorTutorial)
 
 
 Operator Reference <a name="operator_reference"></a>
@@ -447,3 +447,9 @@ ports.
 1. Invoke constructor; non-transients initialized.
 2. Copy state from checkpoint -- initialized values from step 1 are
 replaced.
+
+
+Malhar Operator Library
+==========================
+
+To see the full list of Apex Malhar operators along with related documentation, visit [Apex Malhar on Github](https://github.com/apache/incubator-apex-malhar)

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/cfdacdf2/mkdocs.yml
----------------------------------------------------------------------
diff --git a/mkdocs.yml b/mkdocs.yml
new file mode 100644
index 0000000..c6a26d7
--- /dev/null
+++ b/mkdocs.yml
@@ -0,0 +1,15 @@
+site_name: Apache Apex Documentation
+site_favicon: favicon.ico
+theme: readthedocs
+pages:
+- Apache Apex: index.md
+- Apache Apex-Malhar: apex_malhar.md
+- Development:
+    - Development Setup: apex_development_setup.md
+    - Applications: application_development.md
+    - Application Packages: application_packages.md
+    - Configuration Packages: configuration_packages.md
+    - Operators: operator_development.md
+    - AutoMetric API: autometrics.md
+- Operations:
+    - dtCli: dtcli.md


[09/11] incubator-apex-core git commit: Removing duplicate Apex Malhar page from core docs

Posted by th...@apache.org.
Removing duplicate Apex Malhar page from core docs


Project: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/commit/d26c28a0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/tree/d26c28a0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/diff/d26c28a0

Branch: refs/heads/APEXCORE-293
Commit: d26c28a05f02f7a0f267d0daf1fab6fa024164d4
Parents: 6af9126
Author: Sasha Parfenov <sa...@apache.org>
Authored: Tue Mar 1 19:44:45 2016 -0800
Committer: Sasha Parfenov <sa...@apache.org>
Committed: Tue Mar 1 19:44:45 2016 -0800

----------------------------------------------------------------------
 docs/apex_malhar.md | 59 ------------------------------------------------
 docs/index.md       |  3 +--
 mkdocs.yml          |  1 -
 3 files changed, 1 insertion(+), 62 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/d26c28a0/docs/apex_malhar.md
----------------------------------------------------------------------
diff --git a/docs/apex_malhar.md b/docs/apex_malhar.md
deleted file mode 100644
index 45dee76..0000000
--- a/docs/apex_malhar.md
+++ /dev/null
@@ -1,59 +0,0 @@
-Apache Apex Malhar
-================================================================================
-
-Apache Apex Malhar is an open source operator and codec library that can be used with the [Apache Apex](http://apex.apache.org/) platform to build real-time streaming applications.  Enabling users to extract value quickly, Malhar operators help get data in, analyze it in real-time, and get data out of Hadoop.  In addition to the operators, the library contains a number of demos applications, demonstrating operator features and capabilities.  To see the full list of available operators and related documentation, visit [Apex Malhar on Github](https://github.com/apache/incubator-apex-malhar)
-
-![MalharDiagram](images/malhar-operators.png)
-
-# Capabilities common across Malhar operators
-
-For most streaming platforms, connectors are afterthoughts and often end up being simple ‘bolt-ons’ to the platform. As a result they often cause performance issues or data loss when put through failure scenarios and scalability requirements. Malhar operators do not face these issues as they were designed to be integral parts of Apex. Hence, they have following core streaming runtime capabilities
-
-1.  **Fault tolerance** – Malhar operators where applicable have fault tolerance built in. They use the checkpoint capability provided by the framework to ensure that there is no data loss under ANY failure scenario.
-2.  **Processing guarantees** – Malhar operators where applicable provide out of the box support for ALL three processing guarantees – exactly once, at-least once, and at-most once WITHOUT requiring the user to write any additional code.  Some operators, like MQTT operator, deal with source systems that can not track processed data and hence need the operators to keep track of the data.  Malhar has support for a generic operator that uses alternate storage like HDFS to facilitate this.  Finally for databases that support transactions or support any sort of atomic batch operations Malhar operators can do exactly once down to the tuple level.
-3.  **Dynamic updates** – Based on changing business conditions you often have to tweak several parameters used by the operators in your streaming application without incurring any application downtime. You can also change properties of a Malhar operator at runtime without having to bring down the application.
-4.  **Ease of extensibility** – Malhar operators are based on templates that are easy to extend.
-5.  **Partitioning support** – In streaming applications the input data stream often needs to be partitioned based on the contents of the stream. Also for operators that ingest data from external systems partitioning needs to be done based on the capabilities of the external system.  For example with Kafka, the operator can automatically scale up or down based on the changes in the number of Kafka partitions.
-
-# Operator Library Overview
-
-## Input/output connectors
-
-Below is a summary of the various sub categories of input and output operators. Input operators also have a corresponding output operator
-
-*   **File Systems** – Most streaming analytics use cases require the data to be stored in HDFS or perhaps S3 if the application is running in AWS.  Users often need to re-run their streaming analytical applications against historical data or consume data from upstream processes that are perhaps writing to some NFS share.  Apex supports input & output operators for HDFS, S3, NFS & Local Files.  There are also File Splitter and Block Reader operators, which can accelecate processing of large files by splitting and paralellizing the work across non-overlapping sets of file blocks.
-*   **Relational Databases** – Most stream processing use cases require some reference data lookups to enrich, tag or filter streaming data. There is also a need to save results of the streaming analytical computation to a database so an operational dashboard can see them. Apex supports a JDBC operator so you can read/write data from any JDBC compliant RDBMS like Oracle, MySQL, Sqlite, etc.
-*   **NoSQL Databases** – NoSQL key-value pair databases like Cassandra & HBase are a common part of streaming analytics application architectures to lookup reference data or store results.  Malhar has operators for HBase, Cassandra, Accumulo, Aerospike, MongoDB, and CouchDB.
-*   **Messaging Systems** – Kafka, JMS, and similar systems are the workhorses of messaging infrastructure in most enterprises.  Malhar has a robust, industry-tested set of operators to read and write Kafka, JMS, ZeroMQ, and RabbitMQ messages.
-*   **Notification Systems** – Malhar includes an operator for sending notifications via SMTP.
-*   **In-memory Databases & Caching platforms** - Some streaming use cases need instantaneous access to shared state across the application. Caching platforms and in-memory databases serve this purpose really well. To support these use cases, Malhar has operators for memcached and Redis.
-*   **Social Media** - Malhar includes an operator to connect to the popular Twitter stream fire hose.
-*   **Protocols** - Malhar provides connectors that can communicate in HTTP, RSS, Socket, WebSocket, FTP, and MQTT.
-
-## Parsers
-
-There are many industry vertical specific data formats that a streaming application developer might need to parse. Often there are existing parsers available for these that can be directly plugged into an Apache Apex application. For example in the Telco space, a Java based CDR parser can be directly plugged into Apache Apex operator. To further simplify development experience, Malhar also provides some operators for parsing common formats like XML (DOM & SAX), JSON (flat map converter), Apache log files, syslog, etc.
-
-## Stream manipulation
-
-Streaming data inevitably needs processing to clean, filter, tag, summarize, etc. The goal of Malhar is to enable the application developer to focus on WHAT needs to be done to the stream to get it in the right format and not worry about the HOW.  Malhar has several operators to perform the common stream manipulation actions like – GroupBy, Join, Distinct/Unique, Limit, OrderBy, Split, Sample, Inner join, Outer join, Select, Update etc.
-
-## Compute
-
-One of the most important promises of a streaming analytics platform like Apache Apex is the ability to do analytics in real-time. However delivering on the promise becomes really difficult when the platform does not provide out of the box operators to support variety of common compute functions as the user then has to worry about making these scalable, fault tolerant, stateful, etc.  Malhar takes this responsibility away from the application developer by providing a variety of out of the box computational operators.
-
-Below is just a snapshot of the compute operators available in Malhar
-
-*   Statistics and math - Various mathematical and statistical computations over application defined time windows.
-*   Filtering and pattern matching
-*   Sorting, maps, frequency, TopN, BottomN
-*   Random data generators
-
-## Languages Support
-
-Migrating to a new platform often requires re-use of the existing code that would be difficult or time-consuming to re-write.  With this in mind, Malhar supports invocation of code written in other languages by wrapping them in one of the library operators, and allows execution of software written in:
-
-* JavaScript
-* Python
-* R
-* Ruby
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/d26c28a0/docs/index.md
----------------------------------------------------------------------
diff --git a/docs/index.md b/docs/index.md
index 6a78abf..71d4e6b 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -12,8 +12,7 @@ Apex is a Hadoop YARN native big data processing platform, enabling real time st
 
 Platform has been demonstated to scale linearly across Hadoop clusters under extreme loads of billions of events per second.  Hardware and process failures are quickly recovered with HDFS-backed checkpointing and automatic operator recovery, preserving application state and resuming execution in seconds.  Functional and operational specifications are separated.  Apex provides a simple API, which enables users to write generic, reusable code.  The code is dropped in as-is and platform automatically handles the various operational concerns, such as state management, fault tolerance, scalability, security, metrics, etc.  This frees users to focus on functional development, and lets platform provide operability support.
 
-The core Apex platform is supplemented by Malhar, a library of connector and logic functions, enabling rapid application development.  These operators and modules provide access to HDFS, S3, NFS, FTP, and other file systems; Kafka, ActiveMQ, RabbitMQ, JMS, and other message systems; MySql, Cassandra, MongoDB, Redis, HBase, CouchDB, generic JDBC, and other database connectors. The Malhar library also includes a host of other common business logic patterns that help users to significantly reduce the time it takes to go into production.  Ease of integration with all other big data technologies is one of the primary missions of Malhar.
-
+The core Apex platform is supplemented by Malhar, a library of connector and logic functions, enabling rapid application development.  These operators and modules provide access to HDFS, S3, NFS, FTP, and other file systems; Kafka, ActiveMQ, RabbitMQ, JMS, and other message systems; MySql, Cassandra, MongoDB, Redis, HBase, CouchDB, generic JDBC, and other database connectors.  In addition to the operators, the library contains a number of demos applications, demonstrating operator features and capabilities.  To see the full list of available operators and related documentation, visit [Apex Malhar on Github](https://github.com/apache/incubator-apex-malhar)
 
 For additional information visit [Apache Apex (incubating)](http://apex.incubator.apache.org/).
 

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/d26c28a0/mkdocs.yml
----------------------------------------------------------------------
diff --git a/mkdocs.yml b/mkdocs.yml
index c6a26d7..c91718c 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -3,7 +3,6 @@ site_favicon: favicon.ico
 theme: readthedocs
 pages:
 - Apache Apex: index.md
-- Apache Apex-Malhar: apex_malhar.md
 - Development:
     - Development Setup: apex_development_setup.md
     - Applications: application_development.md


[05/11] incubator-apex-core git commit: Migrating docs

Posted by th...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/application_development.md
----------------------------------------------------------------------
diff --git a/application_development.md b/application_development.md
deleted file mode 100644
index a76ad8a..0000000
--- a/application_development.md
+++ /dev/null
@@ -1,2934 +0,0 @@
-Application Developer Guide
-===========================
-
-Real-time big data processing is not only important but has become
-critical for businesses which depend on accurate and timely analysis of
-their business data. A few businesses have yielded to very expensive
-solutions like building an in-house, real-time analytics infrastructure
-supported by an internal development team, or buying expensive
-proprietary software. A large number of businesses are dealing with the
-requirement just by trying to make Hadoop do their batch jobs in smaller
-iterations. Over the last few years, Hadoop has become ubiquitous in the
-big data processing space, replacing expensive proprietary hardware and
-software solutions for massive data processing with very cost-effective,
-fault-tolerant, open-sourced, and commodity-hardware-based solutions.
-While Hadoop has been a game changer for companies, it is primarily a
-batch-oriented system, and does not yet have a viable option for
-real-time data processing.  Most companies with real-time data
-processing end up having to build customized solutions in addition to
-their Hadoop infrastructure.
-
- 
-
-The DataTorrent platform is designed to process massive amounts of
-real-time events natively in Hadoop. This can be event ingestion,
-processing, and aggregation for real-time data analytics, or can be
-real-time business logic decisioning such as cell tower load balancing,
-real-time ads bidding, or fraud detection.  The platform has the ability
-to repair itself in real-time (without data loss) if hardware fails, and
-adapt to changes in load by adding and removing computing resources
-automatically.
-
-
-
-DataTorrent is a native Hadoop application. It runs as a YARN
-(Hadoop 2.x) application and leverages Hadoop as a distributed operating
-system. All the basic distributed operating system capabilities of
-Hadoop like resource allocation (Resource Manager, distributed file system (HDFS),
-multi-tenancy, security, fault-tolerance, scalability, etc.
-are supported natively in all streaming applications.  Just as Hadoop
-for map-reduce handles all the details of the application allowing you
-to only focus on writing the application (the mapper and reducer
-functions), the platform handles all the details of streaming execution,
-allowing you to only focus on your business logic. Using the platform
-removes the need to maintain separate clusters for real-time
-applications.
-
-
-
-In the platform, building a streaming application can be extremely
-easy and intuitive.  The application is represented as a Directed
-Acyclic Graph (DAG) of computation units called *Operators* interconnected
-by the data-flow edges called  *Streams*. The operators process input
-streams and produce output streams. A library of common operators is
-provided to enable quick application development.  In case the desired
-processing is not available in the Operator Library, one can easily
-write a custom operator. We refer those interested in creating their own
-operators to the [Operator Development Guide](operator_development.md).
-
-Running A Test Application
-=======================================
-
-This chapter will help you with a quick start on running an
-application. If you are starting with the platform for the first time,
-it would be informative to open an existing application and see it run.
-Do the following steps to run the PI demo, which computes the value of
-PI  in a simple
-manner:
-
-1.  Open up platform files in your IDE (for example NetBeans, or Eclipse)
-2.  Open Demos project
-3.  Open Test Packages and run ApplicationTest.java in pi package
-4.  See the results in your system console
-
-
-
-Congratulations, you just ran your first real-time streaming demo
-:) This demo is very simple and has four operators. The first operator
-emits random integers between 0 to 30, 000. The second operator receives
-these coefficients and emits a hashmap with x and y values each time it
-receives two values. The third operator takes these values and computes
-x\*\*2+y\*\*2. The last operator counts how many computed values from
-the previous operator were less than or equal to 30, 000\*\*2. Assuming
-this count is N, then PI is computed as N/number of values received.
-Here is the code snippet for the PI application. This code populates the
-DAG. Do not worry about what each line does, we will cover these
-concepts later in this document.
-
-
-```java
-// Generates random numbers
-RandomEventGenerator rand = dag.addOperator("rand", new RandomEventGenerator());
-rand.setMinvalue(0);
-rand.setMaxvalue(30000);
-
-// Generates a round robin HashMap of "x" and "y"
-RoundRobinHashMap<String,Object> rrhm = dag.addOperator("rrhm", new RoundRobinHashMap<String, Object>());
-rrhm.setKeys(new String[] { "x", "y" });
-
-// Calculates pi from x and y
-JavaScriptOperator calc = dag.addOperator("picalc", new Script());
-calc.setPassThru(false);
-calc.put("i",0);
-calc.put("count",0);
-calc.addSetupScript("function pi() { if (x*x+y*y <= "+maxValue*maxValue+") { i++; } count++; return i / count * 4; }");
-calc.setInvoke("pi");
-dag.addStream("rand_rrhm", rand.integer_data, rrhm.data);
-dag.addStream("rrhm_calc", rrhm.map, calc.inBindings);
-
-// puts results on system console
-ConsoleOutputOperator console = dag.addOperator("console", new ConsoleOutputOperator());
-dag.addStream("rand_console",calc.result, console.input);
-```
-
-
-You can review the other demos and see what they do. The examples
-given in the Demos project cover various features of the platform and we
-strongly encourage you to read these to familiarize yourself with the
-platform. In the remaining part of this document we will go through
-details needed for you to develop and run streaming applications in
-Malhar.
-
-Test Application: Yahoo! Finance Quotes
-----------------------------------------------------
-
-The PI application was to
-get you started. It is a basic application and does not fully illustrate
-the features of the platform. For the purpose of describing concepts, we
-will consider the test application shown in Figure 1. The application
-downloads tick data from  [Yahoo! Finance](http://finance.yahoo.com)  and computes the
-following for four tickers, namely [IBM](http://finance.yahoo.com/q?s=IBM),
-[GOOG](http://finance.yahoo.com/q?s=GOOG), [YHOO](http://finance.yahoo.com/q?s=YHOO).
-
-1.  Quote: Consisting of last trade price, last trade time, and
-    total volume for the day
-2.  Per-minute chart data: Highest trade price, lowest trade
-    price, and volume during that minute
-3.  Simple Moving Average: trade price over 5 minutes
-
-
-Total volume must ensure that all trade volume for that day is
-added, i.e. data loss would result in wrong results. Charting data needs
-all the trades in the same minute to go to the same slot, and then on it
-starts afresh, so again data loss would result in wrong results. The
-aggregation for charting data is done over 1 minute. Simple moving
-average computes the average price over a 5 minute sliding window; it
-too would produce wrong results if there is data loss. Figure 1 shows
-the application with no partitioning.
-
-
-
-![](images/application_development/ApplicationDeveloperGuide.html-image00.png)
-
-
-
-The operator StockTickerInput: StockTickerInput[ ](http://docs.google.com/../apidocs/com/datatorrent/demos/yahoofinance/StockTickInput.html)is
-the input operator that reads live data from Yahoo! Finance once per
-interval (user configurable in milliseconds), and emits the price, the
-incremental volume, and the last trade time of each stock symbol, thus
-emulating real ticks from the exchange.  We utilize the Yahoo! Finance
-CSV web service interface.  For example:
-
-
-```
-$ GET 'http://download.finance.yahoo.com/d/quotes.csv?s=IBM,GOOG,AAPL,YHOO&f=sl1vt1'
-"IBM",203.966,1513041,"1:43pm"
-"GOOG",762.68,1879741,"1:43pm"
-"AAPL",444.3385,11738366,"1:43pm"
-"YHOO",19.3681,14707163,"1:43pm"
-```
-
-
-Among all the operators in Figure 1, StockTickerInput is the only
-operator that requires extra code because it contains a custom mechanism
-to get the input data.  Other operators are used unchanged from the
-Malhar library.
-
-
-Here is the class implementation for StockTickInput:
-
-
-```java
-package com.datatorrent.demos.yahoofinance;
-
-import au.com.bytecode.opencsv.CSVReader;
-import com.datatorrent.annotation.OutputPortFieldAnnotation;
-import com.datatorrent.api.Context.OperatorContext;
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.api.InputOperator;
-import com.datatorrent.lib.util.KeyValPair;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.*;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.httpclient.cookie.CookiePolicy;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.params.DefaultHttpParams;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * This operator sends price, volume and time into separate ports and calculates incremental volume.
- */
-public class StockTickInput implements InputOperator
-{
-  private static final Logger logger = LoggerFactory.getLogger(StockTickInput.class);
-  /**
-   * Timeout interval for reading from server. 0 or negative indicates no timeout.
-   */
-  public int readIntervalMillis = 500;
-  /**
-   * The URL of the web service resource for the POST request.
-   */
-  private String url;
-  public String[] symbols;
-  private transient HttpClient client;
-  private transient GetMethod method;
-  private HashMap<String, Long> lastVolume = new HashMap<String, Long>();
-  private boolean outputEvenIfZeroVolume = false;
-  /**
-   * The output port to emit price.
-   */
-  @OutputPortFieldAnnotation(optional = true)
-  public final transient DefaultOutputPort<KeyValPair<String, Double>> price = new DefaultOutputPort<KeyValPair<String, Double>>();
-  /**
-   * The output port to emit incremental volume.
-   */
-  @OutputPortFieldAnnotation(optional = true)
-  public final transient DefaultOutputPort<KeyValPair<String, Long>> volume = new DefaultOutputPort<KeyValPair<String, Long>>();
-  /**
-   * The output port to emit last traded time.
-   */
-  @OutputPortFieldAnnotation(optional = true)
-  public final transient DefaultOutputPort<KeyValPair<String, String>> time = new DefaultOutputPort<KeyValPair<String, String>>();
-
-  /**
-   * Prepare URL from symbols and parameters. URL will be something like: http://download.finance.yahoo.com/d/quotes.csv?s=IBM,GOOG,AAPL,YHOO&f=sl1vt1
-   *
-   * @return the URL
-   */
-  private String prepareURL()
-  {
-    String str = "http://download.finance.yahoo.com/d/quotes.csv?s=";
-    for (int i = 0; i < symbols.length; i++) {
-      if (i != 0) {
-        str += ",";
-      }
-      str += symbols[i];
-    }
-    str += "&f=sl1vt1&e=.csv";
-    return str;
-  }
-
-  @Override
-  public void setup(OperatorContext context)
-  {
-    url = prepareURL();
-    client = new HttpClient();
-    method = new GetMethod(url);
-    DefaultHttpParams.getDefaultParams().setParameter("http.protocol.cookie-policy", CookiePolicy.BROWSER_COMPATIBILITY);
-  }
-
-  @Override
-  public void teardown()
-  {
-  }
-
-  @Override
-  public void emitTuples()
-  {
-
-    try {
-      int statusCode = client.executeMethod(method);
-      if (statusCode != HttpStatus.SC_OK) {
-        System.err.println("Method failed: " + method.getStatusLine());
-      }
-      else {
-        InputStream istream = method.getResponseBodyAsStream();
-        // Process response
-        InputStreamReader isr = new InputStreamReader(istream);
-        CSVReader reader = new CSVReader(isr);
-        List<String[]> myEntries = reader.readAll();
-        for (String[] stringArr: myEntries) {
-          ArrayList<String> tuple = new ArrayList<String>(Arrays.asList(stringArr));
-          if (tuple.size() != 4) {
-            return;
-          }
-          // input csv is <Symbol>,<Price>,<Volume>,<Time>
-          String symbol = tuple.get(0);
-          double currentPrice = Double.valueOf(tuple.get(1));
-          long currentVolume = Long.valueOf(tuple.get(2));
-          String timeStamp = tuple.get(3);
-          long vol = currentVolume;
-          // Sends total volume in first tick, and incremental volume afterwards.
-          if (lastVolume.containsKey(symbol)) {
-            vol -= lastVolume.get(symbol);
-          }
-
-          if (vol > 0 || outputEvenIfZeroVolume) {
-            price.emit(new KeyValPair<String, Double>(symbol, currentPrice));
-            volume.emit(new KeyValPair<String, Long>(symbol, vol));
-            time.emit(new KeyValPair<String, String>(symbol, timeStamp));
-            lastVolume.put(symbol, currentVolume);
-          }
-        }
-      }
-      Thread.sleep(readIntervalMillis);
-    }
-    catch (InterruptedException ex) {
-      logger.debug(ex.toString());
-    }
-    catch (IOException ex) {
-      logger.debug(ex.toString());
-    }
-  }
-
-  @Override
-  public void beginWindow(long windowId)
-  {
-  }
-
-  @Override
-  public void endWindow()
-  {
-  }
-
-  public void setOutputEvenIfZeroVolume(boolean outputEvenIfZeroVolume)
-  {
-	   this.outputEvenIfZeroVolume = outputEvenIfZeroVolume;
-  }
-
-}
-```
-
-
-
-The operator has three output ports that emit the price of the
-stock, the volume of the stock and the last trade time of the stock,
-declared as public member variables price, volume and  time of the class.  The tuple of the
-price output port is a key-value
-pair with the stock symbol being the key, and the price being the value.
- The tuple of the volume output
-port is a key value pair with the stock symbol being the key, and the
-incremental volume being the value.  The tuple of the  time output port is a key value pair with the
-stock symbol being the key, and the last trade time being the
-value.
-
-
-
-Important: Since operators will be
-serialized, all input and output ports need to be declared transient
-because they are stateless and should not be serialized.
-
-
-
-The method setup(OperatorContext)
-contains the code that is necessary for setting up the HTTP
-client for querying Yahoo! Finance.
-
-
-
-Method emitTuples() contains
-the code that reads from Yahoo! Finance, and emits the data to the
-output ports of the operator.  emitTuples() will be called one or more times
-within one application window as long as time is allowed within the
-window.
-
-
-
-Note that we want to emulate the tick input stream by having
-incremental volume data with Yahoo! Finance data.  We therefore subtract
-the previous volume from the current volume to emulate incremental
-volume for each tick.
-
-
-
-The operator
-DailyVolume: This operator
-reads from the input port, which contains the incremental volume tuples
-from StockTickInput, and
-aggregates the data to provide the cumulative volume.  It uses the
-library class  SumKeyVal&lt;K,V&gt; provided in math package.  In this case,
-SumKeyVal&lt;String,Long&gt;, where K is the stock symbol, V is the
-aggregated volume, with cumulative
-set to true. (Otherwise if  cumulativewas set to false, SumKeyVal would
-provide the sum for the application window.)  Malhar provides a number
-of built-in operators for simple operations like this so that
-application developers do not have to write them.  More examples to
-follow. This operator assumes that the application restarts before the
-market opens every day.
-
-
-
-The operator Quote:
-This operator has three input ports, which are price (from
-StockTickInput), daily_vol (from
-Daily Volume), and time (from
- StockTickInput).  This operator
-just consolidates the three data items and and emits the consolidated
-data.  It utilizes the class ConsolidatorKeyVal&lt;K&gt; from the
-stream package.
-
-
-
-The operator HighLow: This operator reads from the input port,
-which contains the price tuples from StockTickInput, and provides the high and the
-low price within the application window.  It utilizes the library class
- RangeKeyVal&lt;K,V&gt; provided
-in the math package. In this case,
-RangeKeyVal&lt;String,Double&gt;.
-
-
-
-The operator MinuteVolume:
-This operator reads from the input port, which contains the
-volume tuples from StockTickInput,
-and aggregates the data to provide the sum of the volume within one
-minute.  Like the operator  DailyVolume, this operator also uses
-SumKeyVal&lt;String,Long&gt;, but
-with cumulative set to false.  The
-Application Window is set to one minute. We will explain how to set this
-later.
-
-
-
-The operator Chart:
-This operator is very similar to the operator Quote, except that it takes inputs from
-High Low and  Minute Vol and outputs the consolidated tuples
-to the output port.
-
-
-
-The operator PriceSMA:
-SMA stands for - Simple Moving Average. It reads from the
-input port, which contains the price tuples from StockTickInput, and
-provides the moving average price of the stock.  It utilizes
-SimpleMovingAverage&lt;String,Double&gt;, which is provided in the
- multiwindow package.
-SimpleMovingAverage keeps track of the data of the previous N
-application windows in a sliding manner.  For each end window event, it
-provides the average of the data in those application windows.
-
-
-
-The operator Console:
-This operator just outputs the input tuples to the console
-(or stdout).  In this example, there are four console operators, which connect to the output
-of  Quote, Chart, PriceSMA and VolumeSMA.  In
-practice, they should be replaced by operators that use the data to
-produce visualization artifacts like charts.
-
-
-
-Connecting the operators together and constructing the
-DAG: Now that we know the
-operators used, we will create the DAG, set the streaming window size,
-instantiate the operators, and connect the operators together by adding
-streams that connect the output ports with the input ports among those
-operators.  This code is in the file  YahooFinanceApplication.java. Refer to Figure 1
-again for the graphical representation of the DAG.  The last method in
-the code, namely getApplication(),
-does all that.  The rest of the methods are just for setting up the
-operators.
-
-
-
-```java
-package com.datatorrent.demos.yahoofinance;
-
-import com.datatorrent.api.ApplicationFactory;
-import com.datatorrent.api.Context.OperatorContext;
-import com.datatorrent.api.DAG;
-import com.datatorrent.api.Operator.InputPort;
-import com.datatorrent.lib.io.ConsoleOutputOperator;
-import com.datatorrent.lib.math.RangeKeyVal;
-import com.datatorrent.lib.math.SumKeyVal;
-import com.datatorrent.lib.multiwindow.SimpleMovingAverage;
-import com.datatorrent.lib.stream.ConsolidatorKeyVal;
-import com.datatorrent.lib.util.HighLow;
-import org.apache.hadoop.conf.Configuration;
-
-/**
- * Yahoo! Finance application demo. <p>
- *
- * Get Yahoo finance feed and calculate minute price range, minute volume, simple moving average of 5 minutes.
- */
-public class Application implements StreamingApplication
-{
-  private int streamingWindowSizeMilliSeconds = 1000; // 1 second (default is 500ms)
-  private int appWindowCountMinute = 60;   // 1 minute
-  private int appWindowCountSMA = 5 * 60;  // 5 minute
-
-  /**
-   * Get actual Yahoo finance ticks of symbol, last price, total daily volume, and last traded price.
-   */
-  public StockTickInput getStockTickInputOperator(String name, DAG dag)
-  {
-    StockTickInput oper = dag.addOperator(name, StockTickInput.class);
-    oper.readIntervalMillis = 200;
-    return oper;
-  }
-
-  /**
-   * This sends total daily volume by adding volumes from each ticks.
-   */
-  public SumKeyVal<String, Long> getDailyVolumeOperator(String name, DAG dag)
-  {
-    SumKeyVal<String, Long> oper = dag.addOperator(name, new SumKeyVal<String, Long>());
-    oper.setType(Long.class);
-    oper.setCumulative(true);
-    return oper;
-  }
-
-  /**
-   * Get aggregated volume of 1 minute and send at the end window of 1 minute.
-   */
-  public SumKeyVal<String, Long> getMinuteVolumeOperator(String name, DAG dag, int appWindowCount)
-  {
-    SumKeyVal<String, Long> oper = dag.addOperator(name, new SumKeyVal<String, Long>());
-    oper.setType(Long.class);
-    oper.setEmitOnlyWhenChanged(true);
-dag.getOperatorMeta(name).getAttributes().put(OperatorContext.APPLICATION_WINDOW_COUNT,appWindowCount);
-    return oper;
-  }
-
-  /**
-   * Get High-low range for 1 minute.
-   */
-  public RangeKeyVal<String, Double> getHighLowOperator(String name, DAG dag, int appWindowCount)
-  {
-    RangeKeyVal<String, Double> oper = dag.addOperator(name, new RangeKeyVal<String, Double>());
-    dag.getOperatorMeta(name).getAttributes().put(OperatorContext.APPLICATION_WINDOW_COUNT,appWindowCount);
-    oper.setType(Double.class);
-    return oper;
-  }
-
-  /**
-   * Quote (Merge price, daily volume, time)
-   */
-  public ConsolidatorKeyVal<String,Double,Long,String,?,?> getQuoteOperator(String name, DAG dag)
-  {
-    ConsolidatorKeyVal<String,Double,Long,String,?,?> oper = dag.addOperator(name, new ConsolidatorKeyVal<String,Double,Long,String,Object,Object>());
-    return oper;
-  }
-
-  /**
-   * Chart (Merge minute volume and minute high-low)
-   */
-  public ConsolidatorKeyVal<String,HighLow,Long,?,?,?> getChartOperator(String name, DAG dag)
-  {
-    ConsolidatorKeyVal<String,HighLow,Long,?,?,?> oper = dag.addOperator(name, new ConsolidatorKeyVal<String,HighLow,Long,Object,Object,Object>());
-    return oper;
-  }
-
-  /**
-   * Get simple moving average of price.
-   */
-  public SimpleMovingAverage<String, Double> getPriceSimpleMovingAverageOperator(String name, DAG dag, int appWindowCount)
-  {
-    SimpleMovingAverage<String, Double> oper = dag.addOperator(name, new SimpleMovingAverage<String, Double>());
-    oper.setWindowSize(appWindowCount);
-    oper.setType(Double.class);
-    return oper;
-  }
-
-  /**
-   * Get console for output.
-   */
-  public InputPort<Object> getConsole(String name, /*String nodeName,*/ DAG dag, String prefix)
-  {
-    ConsoleOutputOperator oper = dag.addOperator(name, ConsoleOutputOperator.class);
-    oper.setStringFormat(prefix + ": %s");
-    return oper.input;
-  }
-
-  /**
-   * Create Yahoo Finance Application DAG.
-   */
-  @Override
-  public void populateDAG(DAG dag, Configuration conf)
-  {
-    dag.getAttributes().put(DAG.STRAM_WINDOW_SIZE_MILLIS,streamingWindowSizeMilliSeconds);
-
-    StockTickInput tick = getStockTickInputOperator("StockTickInput", dag);
-    SumKeyVal<String, Long> dailyVolume = getDailyVolumeOperator("DailyVolume", dag);
-    ConsolidatorKeyVal<String,Double,Long,String,?,?> quoteOperator = getQuoteOperator("Quote", dag);
-
-    RangeKeyVal<String, Double> highlow = getHighLowOperator("HighLow", dag, appWindowCountMinute);
-    SumKeyVal<String, Long> minuteVolume = getMinuteVolumeOperator("MinuteVolume", dag, appWindowCountMinute);
-    ConsolidatorKeyVal<String,HighLow,Long,?,?,?> chartOperator = getChartOperator("Chart", dag);
-
-    SimpleMovingAverage<String, Double> priceSMA = getPriceSimpleMovingAverageOperator("PriceSMA", dag, appWindowCountSMA);
-       DefaultPartitionCodec<String, Double> codec = new DefaultPartitionCodec<String, Double>();
-    dag.setInputPortAttribute(highlow.data, PortContext.STREAM_CODEC, codec);
-    dag.setInputPortAttribute(priceSMA.data, PortContext.STREAM_CODEC, codec);
-    dag.addStream("price", tick.price, quoteOperator.in1, highlow.data, priceSMA.data);
-    dag.addStream("vol", tick.volume, dailyVolume.data, minuteVolume.data);
-    dag.addStream("time", tick.time, quoteOperator.in3);
-    dag.addStream("daily_vol", dailyVolume.sum, quoteOperator.in2);
-
-    dag.addStream("quote_data", quoteOperator.out, getConsole("quoteConsole", dag, "QUOTE"));
-
-    dag.addStream("high_low", highlow.range, chartOperator.in1);
-    dag.addStream("vol_1min", minuteVolume.sum, chartOperator.in2);
-    dag.addStream("chart_data", chartOperator.out, getConsole("chartConsole", dag, "CHART"));
-
-    dag.addStream("sma_price", priceSMA.doubleSMA, getConsole("priceSMAConsole", dag, "Price SMA"));
-
-    return dag;
-  }
-
-}
-```
-
-
-
-Note that we also set a user-specific sliding window for SMA that
-keeps track of the previous N data points.  Do not confuse this with the
-attribute APPLICATION_WINDOW_COUNT.
-
-In the rest of this chapter we will run through the process of
-running this application. We assume that  you are familiar with details
-of your Hadoop infrastructure. For installation
-details please refer to the [Installation Guide](installation.md).
-
-
-Running a Test Application
------------------------------------------
-
-We will now describe how to run the yahoo
-finance application described above in different modes
-(local mode, single node on Hadoop, and multi-nodes on Hadoop).
-
-
-The platform runs streaming applications under the control of a
-light-weight Streaming Application Manager (STRAM). Each application has
-its own instance of STRAM. STRAM launches the application and
-continually provides run time monitoring, analysis, and takes action
-such as load scaling or outage recovery as needed.  We will discuss
-STRAM in more detail in the next chapter.
-
-
-
-The instructions below assume that the platform was installed in a
-directory &lt;INSTALL_DIR&gt; and the command line interface (CLI) will
-be used to launch the demo application. An application can be run in
-[local mode](#h.3dy6vkm)[ ](#h.3dy6vkm)(in IDE or from command line) or on a  [Hadoop cluster](#h.1t3h5sf) [.](#h.1t3h5sf)
-
-
-
-To start the dtCli run
-
-    <INSTALL_DIR>/bin/dtcli
-
-The command line prompt appears.  To start the application in local mode (the actual version number in the file name may differ)
-
-    dt> launch -local <INSTALL_DIR>/yahoo-finance-demo-3.2.0-SNAPSHOT.apa
-
-To terminate the application in local mode, enter Ctrl-C
-
-Tu run the application on the Hadoop cluster (the actual version
-number in the file name may differ)
-
-    dt> launch <INSTALL_DIR>/yahoo-finance-demo-3.2.0-SNAPSHOT.apa
-
-
-To stop the application running in Hadoop, terminate it in the dtCli:
-
-    dt> kill-app
-
-
-
-Executing the application in either mode includes the following
-steps. At a top level, STRAM (Streaming Application Manager) validates
-the application (DAG), translates the logical plan to the physical plan
-and then launches the execution engine. The mode determines the
-resources needed and how how they are used.
-
-Local Mode
------------------------
-
-In local mode, the application is run as a single-process with multiple threads. Although a
-few Hadoop classes are needed, there is no dependency on a Hadoop
-cluster or Hadoop services. The local file system is used in place of
-HDFS. This mode allows a quick run of an application in a single process
-sandbox, and hence is the most suitable to debug and analyze the
-application logic. This mode is recommended for developing the
-application and can be used for running applications within the IDE for
-functional testing purposes. Due to limited resources and lack  of
-scalability an application running in this single process mode is more
-likely to encounter throughput bottlenecks. A distributed cluster is
-recommended for benchmarking and production testing.
-
-Hadoop Cluster
----------------------------
-
-In this section we discuss various Hadoop cluster setups.
-
-### Single Node Cluster
-
-In a single node Hadoop cluster all services are deployed on a
-single server (a developer can use his/her development machine as a
-single node cluster). The platform does not distinguish between a single
-or multi-node setup and behaves exactly the same in both cases.
-
-
-
-In this mode, the resource manager, name node, data node, and node
-manager occupy one process each. This is an example of running a
-streaming application as a multi-process application on the same server.
-With prevalence of fast, multi-core systems, this mode is effective for
-debugging, fine tuning, and generic analysis before submitting the job
-to a larger Hadoop cluster. In this mode, execution uses the Hadoop
-services and hence is likely to identify issues that are related to the
-Hadoop environment (such issues will not be uncovered in local mode).
-The throughput will obviously not be as high as on a multi-node Hadoop
-cluster. Additionally, since each container (i.e. Java process) requires
-a significant amount of memory, you will be able to run a much smaller
-number of containers than on a multi-node cluster.
-
-### Multi-Node Cluster
-
-In a multi-node Hadoop cluster all the services of Hadoop are
-typically distributed across multiple nodes in a production or
-production-level test environment. Upon launch the application is
-submitted to the Hadoop cluster and executes as a  multi-processapplication on multiple nodes.
-
-
-
-Before you start deploying, testing and troubleshooting your
-application on a cluster, you should ensure that Hadoop (version 2.2.0
-or later) is properly installed and
-you have basic skills for working with it.
-
-------------------------------------------------------------------------
-
-
-
-
-
-Apache Apex Platform Overview
-========================================
-
-Streaming Computational Model
-------------------------------------------
-
-In this chapter, we describe the the basics of the real-time streaming platform and its computational model.
-
-
-The platform is designed to enable completely asynchronous real time computations done in as unblocked a way as possible with
-minimal overhead .
-
-
-
-Applications running in the platform are represented by a Directed
-Acyclic Graph (DAG) made up of  operators and streams. All computations
-are done in memory on arrival of
-the input data, with an option to save the output to disk (HDFS) in a
-non-blocking way. The data that flows between operators consists of
-atomic data elements. Each data element along with its type definition
-(henceforth called  schema) is
-called a tuple. An application is a
-design of the flow of these tuples to and from
-the appropriate compute units to enable the computation of the final
-desired results. A message queue (henceforth called
- buffer server) manages tuples streaming
-between compute units in different processes.This server keeps track of
-all consumers, publishers, partitions, and enables replay. More
-information is given in later section.
-
-
-
-The streaming application is monitored by a decision making entity
-called STRAM (streaming application
-manager). STRAM is designed to be a light weight
-controller that has minimal but sufficient interaction with the
-application. This is done via periodic heartbeats. The
-STRAM does the initial launch and periodically analyzes the system
-metrics to decide if any run time action needs to be taken.
-
-
-
-A fundamental building block for the streaming platform
-is the concept of breaking up a stream into equal finite time slices
-called streaming windows. Each window contains the ordered
-set of tuples in that time slice. A typical duration of a window is 500
-ms, but can be configured per application (the Yahoo! Finance
-application configures this value in the  properties.xml file to be 1000ms = 1s). Each
-window is preceded by a begin_window event and is terminated by an
-end_window event, and is assigned
-a unique window ID. Even though the platform performs computations at
-the tuple level, bookkeeping is done at the window boundary, making the
-computations within a window an atomic event in the platform.  We can
-think of each window as an  atomic
-micro-batch of tuples, to be processed together as one
-atomic operation (See Figure 2).  
-
-
-
-This atomic batching allows the platform to avoid the very steep
-per tuple bookkeeping cost and instead has a manageable per batch
-bookkeeping cost. This translates to higher throughput, low recovery
-time, and higher scalability. Later in this document we illustrate how
-the atomic micro-batch concept allows more efficient optimization
-algorithms.
-
-
-
-The platform also has in-built support for
-application windows.  An application window is part of the
-application specification, and can be a small or large multiple of the
-streaming window.  An example from our Yahoo! Finance test application
-is the moving average, calculated over a sliding application window of 5
-minutes which equates to 300 (= 5 \* 60) streaming windows.
-
-
-
-Note that these two window concepts are distinct.  A streaming
-window is an abstraction of many tuples into a higher atomic event for
-easier management.  An application window is a group of consecutive
-streaming windows used for data aggregation (e.g. sum, average, maximum,
-minimum) on a per operator level.
-
-![](images/application_development/ApplicationDeveloperGuide.html-image02.png)
-
-Alongside the platform, a set of
-predefined, benchmarked standard library operator templates is provided
-for ease of use and rapid development of application. These
-operators are open sourced to Apache Software Foundation under the
-project name “Malhar” as part of our efforts to foster community
-innovation. These operators can be used in a DAG as is, while others
-have  [properties](#h.32hioqz)
-[ ](#h.32hioqz)that can be set to specify the
-desired computation. Those interested in details, should refer to
-[Apex Malhar Operator Library](apex_malhar.md)
-.
-
-
-
-The platform is a Hadoop YARN native
-application. It runs in a Hadoop cluster just like any
-other YARN application (MapReduce etc.) and is designed to seamlessly
-integrate with rest of Hadoop technology stack. It leverages Hadoop as
-much as possible and relies on it as its distributed operating system.
-Hadoop dependencies include resource management, compute/memory/network
-allocation, HDFS, security, fault tolerance, monitoring, metrics,
-multi-tenancy, logging etc. Hadoop classes/concepts are reused as much
-as possible.  The aim is to enable enterprises
-to leverage their existing Hadoop infrastructure for real time streaming
-applications. The platform is designed to scale with big
-data applications and scale with Hadoop.
-
-
-
-A streaming application is an asynchronous execution of
-computations across distributed nodes. All computations are done in
-parallel on a distributed cluster. The computation model is designed to
-do as many parallel computations as possible in a non-blocking fashion.
-The task of monitoring of the entire application is done on (streaming)
-window boundaries with a streaming window as an atomic entity. A window
-completion is a quantum of work done. There is no assumption that an
-operator can be interrupted at precisely a particular tuple or window.
-
-
-
-
-An operator itself also
-cannot assume or predict the exact time a tuple that it emitted would
-get consumed by downstream operators. The operator processes the tuples
-it gets and simply emits new tuples based on its business logic. The
-only guarantee it has is that the upstream operators are processing
-either the current or some later window, and the downstream operator is
-processing either the current or some earlier window. The completion of
-a window (i.e. propagation of the  end_window event through an operator) in any
-operator guarantees that all upstream operators have finished processing
-this window. Thus, the end_window event is blocking on an operator
-with multiple outputs, and is a synchronization point in the DAG. The
- begin_window event does not have
-any such restriction, a single begin_window event from any upstream operator
-triggers the operator to start processing tuples.
-
-Streaming Application Manager (STRAM)
---------------------------------------------------
-
-Streaming Application Manager (STRAM) is the Hadoop YARN native
-application master. STRAM is the first process that is activated upon
-application launch and orchestrates the streaming application on the
-platform. STRAM is a lightweight controller process. The
-responsibilities of STRAM include
-
-1.  Running the Application
-
-    *  Read the logical plan of the application (DAG) submitted by the client
-    *  Validate the logical plan
-    *  Translate the logical plan into a physical plan, where certain operators may  be partitioned (i.e. replicated) to multiple operators for  handling load.
-    *  Request resources (Hadoop containers) from Resource Manager,
-        per physical plan
-    *  Based on acquired resources and application attributes, create
-        an execution plan by partitioning the DAG into fragments,
-        each assigned to different containers.
-    *  Executes the application by deploying each fragment to
-        its container. Containers then start stream processing and run
-        autonomously, processing one streaming window after another. Each
-        container is represented as an instance of the  StreamingContainer class, which updates
-        STRAM via the heartbeat protocol and processes directions received
-        from STRAM.
-
-2.  Continually monitoring the application via heartbeats from each StreamingContainer
-3.  Collecting Application System Statistics and Logs
-4.  Logging all application-wide decisions taken
-5.  Providing system data on the state of the application via a  Web Service.
-6.  Supporting [Fault Tolerance](#h.2nusc19)
-
-    a.  Detecting a node outage
-    b.  Requesting a replacement resource from the Resource Manager
-        and scheduling state restoration for the streaming operators
-    c.  Saving state to Zookeeper
-
-7.  Supporting [Dynamic
-    Partitioning](#h.3hv69ve)[:](#h.3hv69ve) Periodically
-    evaluating the SLA and modifying the physical plan if required
-    (logical plan does not change).
-8.  Enabling [Security](#h.3q5sasy)[:](#h.3q5sasy) Distributing
-    security tokens for distributed components of the execution engine
-    and securing web service requests.
-9.  Enabling [Dynamic  modification](#h.40ew0vw)[ ](#h.40ew0vw)of
-    DAG: In the future, we intend to allow for user initiated
-    modification of the logical plan to allow for changes to the
-    processing logic and functionality.
-
-
-
-An example of the Yahoo! Finance Quote application scheduled on a
-cluster of 5 Hadoop containers (processes) is shown in Figure 3.
-
-![](images/application_development/ApplicationDeveloperGuide.html-image01.png)
-
-
-
-An example for the translation from a logical plan to a physical
-plan and an execution plan for a subset of the application is shown in
-Figure 4.
-
-
-
-![](images/application_development/ApplicationDeveloperGuide.html-image04.png)
-
-
-
-
-
-Hadoop Components
-------------------------------
-
-In this section we cover some aspects of Hadoop that your
-streaming application interacts with. This section is not meant to
-educate the reader on Hadoop, but just get the reader acquainted with
-the terms. We strongly advise readers to learn Hadoop from other
-sources.
-
-A streaming application runs as a native Hadoop 2.2 application.
-Hadoop 2.2 does not differentiate between a map-reduce job and other
-applications, and hence as far as Hadoop is concerned, the streaming
-application is just another job. This means that your application
-leverages all the bells and whistles Hadoop provides and is fully
-supported within Hadoop technology stack. The platform is responsible
-for properly integrating itself with the relevant components of Hadoop
-that exist today and those that may emerge in the future
-
-
-
-All investments that leverage multi-tenancy (for example quotas
-and queues), security (for example kerberos), data flow integration (for
-example copying data in-out of HDFS), monitoring, metrics collections,
-etc. will require no changes when streaming applications run on
-Hadoop.
-
-### YARN
-
-[YARN](http://hadoop.apache.org/docs/current/hadoop-yarn/hadoop-yarn-site)is
-the core library of Hadoop 2.2 that is tasked with resource management
-and works as a distributed application framework. In this section we
-will walk through Yarn's components. In Hadoop 2.2, the old jobTracker
-has been replaced by a combination of ResourceManager (RM) and
-ApplicationMaster (AM).
-
-#### Resource Manager (RM)
-
-[ResourceManager](http://hadoop.apache.org/docs/current/hadoop-yarn/hadoop-yarn-site/YARN.html)(RM)
-manages all the distributed resources. It allocates and arbitrates all
-the slots and the resources (cpu, memory, network) of these slots. It
-works with per-node NodeManagers (NMs) and per-application
-ApplicationMasters (AMs). Currently memory usage is monitored by RM; in
-upcoming releases it will have CPU as well as network management. RM is
-shared by map-reduce and streaming applications. Running streaming
-applications requires no changes in the RM.
-
-#### Application Master (AM)
-
-The AM is the watchdog or monitoring process for your application
-and has the responsibility of negotiating resources with RM and
-interacting with NodeManagers to get the allocated containers started.
-The AM is the starting point of your application and is considered user
-code (not system Hadoop code). The AM itself runs in one container. All
-resource management within the application are managed by the AM. This
-is a critical feature for Hadoop 2.2 where tasks done by jobTracker in
-Hadoop 1.0 have been distributed allowing Hadoop 2.2 to scale much
-beyond Hadoop 1.0. STRAM is a native YARN ApplicationManager.
-
-#### Node Managers (NM)
-
-There is one [NodeManager](http://hadoop.apache.org/docs/current/hadoop-yarn/hadoop-yarn-site/YARN.html)(NM)
-per node in the cluster. All the containers (i.e. processes) on that
-node are monitored by the NM. It takes instructions from RM and manages
-resources of that node as per RM instructions. NMs interactions are same
-for map-reduce and for streaming applications. Running streaming
-applications requires no changes in the NM.
-
-#### RPC Protocol
-
-Communication among RM, AM, and NM is done via the Hadoop RPC
-protocol. Streaming applications use the same protocol to send their
-data. No changes are needed in RPC support provided by Hadoop to enable
-communication done by components of your application.
-
-### HDFS
-
-Hadoop includes a highly fault tolerant, high throughput
-distributed file system ([HDFS](http://hadoop.apache.org/docs/r1.0.4/hdfs_design.html)).
-It runs on commodity hardware, and your streaming application will, by
-default, use it. There is no difference between files created by a
-streaming application and those created by map-reduce.
-
-Developing An Application
-======================================
-
-In this chapter we describe the methodology to develop an
-application using the Realtime Streaming Platform. The platform was
-designed to make it easy to build and launch sophisticated streaming
-applications with the developer having to deal only with the
-application/business logic. The platform deals with details of where to
-run what operators on which servers and how to correctly route streams
-of data among them.
-
-Development Process
---------------------------------
-
-While the platform does not mandate a specific methodology or set
-of development tools, we have recommendations to maximize productivity
-for the different phases of application development.
-
-#### Design
-
--   Identify common, reusable operators. Use a library
-    if possible.
--   Identify scalability and performance requirements before
-    designing the DAG.
--   Leverage attributes that the platform supports for scalability
-    and performance.
--   Use operators that are benchmarked and tested so that later
-    surprises are minimized. If you have glue code, create appropriate
-    unit tests for it.
--   Use THREAD_LOCAL locality for high throughput streams. If all
-    the operators on that stream cannot fit in one container,
-    try NODE_LOCAL locality. Both THREAD_LOCAL and
-    NODE_LOCAL streams avoid the Network Interface Card (NIC)
-    completly. The former uses intra-process communication to also avoid
-    serialization-deserialization overhead.
--   The overall throughput and latencies are are not necessarily
-    correlated to the number of operators in a simple way -- the
-    relationship is more nuanced. A lot depends on how much work
-    individual operators are doing, how many are able to operate in
-    parallel, and how much data is flowing through the arcs of the DAG.
-    It is, at times, better to break a computation down into its
-    constituent simple parts and then stitch them together via streams
-    to better utilize the compute resources of the cluster. Decide on a
-    per application basis the fine line between complexity of each
-    operator vs too many streams. Doing multiple computations in one
-    operator does save network I/O, while operators that are too complex
-    are hard to maintain.
--   Do not use operators that depend on the order of two streams
-    as far as possible. In such cases behavior is not idempotent.
--   Persist key information to HDFS if possible; it may be useful
-    for debugging later.
--   Decide on an appropriate fault tolerance mechanism. If some
-    data loss is acceptable, use the at-most-once mechanism as it has
-    fastest recovery.
-
-#### Creating New Project
-
-Please refer to the [Apex Application Packages](application_packages.md) for
-the basic steps for creating a new project.
-
-#### Writing the application code
-
-Preferably use an IDE (Eclipse, Netbeans etc.) that allows you to
-manage dependencies and assists with the Java coding. Specific benefits
-include ease of managing operator library jar files, individual operator
-classes, ports and properties. It will also highlight and assist to
-rectify issues such as type mismatches when adding streams while
-typing.
-
-#### Testing
-
-Write test cases with JUnit or similar test framework so that code
-is tested as it is written. For such testing, the DAG can run in local
-mode within the IDE. Doing this may involve writing mock input or output
-operators for the integration points with external systems. For example,
-instead of reading from a live data stream, the application in test mode
-can read from and write to files. This can be done with a single
-application DAG by instrumenting a test mode using settings in the
-configuration that is passed to the application factory
-interface.
-
-Good test coverage will not only eliminate basic validation errors
-such as missing port connections or property constraint violations, but
-also validate the correct processing of the data. The same tests can be
-re-run whenever the application or its dependencies change (operator
-libraries, version of the platform etc.)
-
-#### Running an application
-
-The platform provides a commandline tool called dtcli for managing applications (launching,
-killing, viewing, etc.). This tool was already discussed above briefly
-in the section entitled Running the Test Application. It will introspect
-the jar file specified with the launch command for applications (classes
-that implement ApplicationFactory) or property files that define
-applications. It will also deploy the dependency jar files from the
-application package to the cluster.
-
-
-
-Dtcli can run the application in local mode (i.e. outside a
-cluster). It is recommended to first run the application in local mode
-in the development environment before launching on the Hadoop cluster.
-This way some of the external system integration and correct
-functionality of the application can be verified in an easier to debug
-environment before testing distributed mode.
-
-
-
-For more details on CLI please refer to the [dtCli Guide](dtcli.md).
-
-Application API
-----------------------------
-
-This section introduces the API to write a streaming application.
-The work involves connecting operators via streams to form the logical
-DAG. The steps are
-
-1.  Instantiate an application (DAG)
-
-2.  (Optional) Set Attributes
-    *  Assign application name
-    *  Set any other attributes as per application requirements
-
-3.  Create/re-use and instantiate operators
-    *  Assign operator name that is unique within the  application
-    *  Declare schema upfront for each operator (and thereby its  [ports](#h.ihv636)[)](#h.ihv636)
-    *  (Optional) Set [properties](#h.32hioqz)[ ](#h.32hioqz) and [attributes](#h.41mghml)[ ](#h.41mghml) on the dag as per specification
-    *  Connect ports of operators via streams
-        *  Each stream connects one output port of an operator to one or  more input ports of other operators.
-        *  (Optional) Set attributes on the streams
-
-4.  Test the application.
-
-
-
-There are two methods to create an application, namely Java, and
-Properties file. Java API is for applications being developed by humans,
-and properties file (Hadoop like) is more suited for DAGs generated by
-tools.
-
-### Java API
-
-The Java API is the most common way to create a streaming
-application. It is meant for application developers who prefer to
-leverage the features of Java, and the ease of use and enhanced
-productivity provided by IDEs like NetBeans or Eclipse. Using Java to
-specify the application provides extra validation abilities of Java
-compiler, such as compile time checks for type safety at the time of
-writing the code. Later in this chapter you can read more about
-validation support in the platform.
-
-The developer specifies the streaming application by implementing
-the ApplicationFactory interface, which is how platform tools (CLI etc.)
-recognize and instantiate applications. Here we show how to create a
-Yahoo! Finance application that streams the last trade price of a ticker
-and computes the high and low price in every 1 min window. Run above
- test application to execute the
-DAG in local mode within the IDE.
-
-
-
-Let us revisit how the Yahoo! Finance test application constructs the DAG:
-
-
-
-```java
-public class Application implements StreamingApplication
-{
-
-  ...
-
-  @Override
-  public void populateDAG(DAG dag, Configuration conf)
-  {
-    dag.getAttributes().attr(DAG.STRAM_WINDOW_SIZE_MILLIS).set(streamingWindowSizeMilliSeconds);
-
-    StockTickInput tick = getStockTickInputOperator("StockTickInput", dag);
-    SumKeyVal<String, Long> dailyVolume = getDailyVolumeOperator("DailyVolume", dag);
-    ConsolidatorKeyVal<String,Double,Long,String,?,?> quoteOperator = getQuoteOperator("Quote", dag);
-
-    RangeKeyVal<String, Double> highlow = getHighLowOperator("HighLow", dag, appWindowCountMinute);
-    SumKeyVal<String, Long> minuteVolume = getMinuteVolumeOperator("MinuteVolume", dag, appWindowCountMinute);
-    ConsolidatorKeyVal<String,HighLow,Long,?,?,?> chartOperator = getChartOperator("Chart", dag);
-
-    SimpleMovingAverage<String, Double> priceSMA = getPriceSimpleMovingAverageOperator("PriceSMA", dag, appWindowCountSMA);
-
-    dag.addStream("price", tick.price, quoteOperator.in1, highlow.data, priceSMA.data);
-    dag.addStream("vol", tick.volume, dailyVolume.data, minuteVolume.data);
-    dag.addStream("time", tick.time, quoteOperator.in3);
-    dag.addStream("daily_vol", dailyVolume.sum, quoteOperator.in2);
-
-    dag.addStream("quote_data", quoteOperator.out, getConsole("quoteConsole", dag, "QUOTE"));
-
-    dag.addStream("high_low", highlow.range, chartOperator.in1);
-    dag.addStream("vol_1min", minuteVolume.sum, chartOperator.in2);
-    dag.addStream("chart_data", chartOperator.out, getConsole("chartConsole", dag, "CHART"));
-
-    dag.addStream("sma_price", priceSMA.doubleSMA, getConsole("priceSMAConsole", dag, "Price SMA"));
-
-    return dag;
-  }
-}
-```
-
-
-
-
-### Property File API
-
-The platform also supports specification of a DAG via a property
-file. The aim here to make it easy for tools to create and run an
-application. This method of specification does not have the Java
-compiler support of compile time check, but since these applications
-would be created by software, they should be correct by construction.
-The syntax is derived from Hadoop properties and should be easy for
-folks who are used to creating software that integrated with
-Hadoop.
-
-
-
-Create an application (DAG): myApplication.properties
-
-
-```
-# input operator that reads from a file
-dt.operator.inputOp.classname=com.acme.SampleInputOperator
-dt.operator.inputOp.fileName=somefile.txt
-
-# output operator that writes to the console
-dt.operator.outputOp.classname=com.acme.ConsoleOutputOperator
-
-# stream connecting both operators
-dt.stream.inputStream.source=inputOp.outputPort
-dt.stream.inputStream.sinks=outputOp.inputPort
-```
-
-
-
-Above snippet is intended to convey the basic idea of specifying
-the DAG without using Java. Operators would come from a predefined
-library and referenced in the specification by class name and port names
-(obtained from the library providers documentation or runtime
-introspection by tools). For those interested in details, see later
-sections and refer to the  Operation and
-Installation Guide mentioned above.
-
-### Attributes
-
-Attributes impact the runtime behavior of the application. They do
-not impact the functionality. An example of an attribute is application
-name. Setting it changes the application name. Another example is
-streaming window size. Setting it changes the streaming window size from
-the default value to the specified value. Users cannot add new
-attributes, they can only choose from the ones that come packaged and
-pre-supported by the platform. Details of attributes are covered in the
- Operation and Installation
-Guide.
-
-Operators
-----------------------
-
-Operators are basic compute units.
-Operators process each incoming tuple and emit zero or more tuples on
-output ports as per the business logic. The data flow, connectivity,
-fault tolerance (node outage), etc. is taken care of by the platform. As
-an operator developer, all that is needed is to figure out what to do
-with the incoming tuple and when (and which output port) to send out a
-particular output tuple. Correctly designed operators will most likely
-get reused. Operator design needs care and foresight. For details, refer
-to the  [Operator Developer Guide](operator_development.md). As an application developer you need to connect operators
-in a way that it implements your business logic. You may also require
-operator customization for functionality and use attributes for
-performance/scalability etc.
-
-
-
-All operators process tuples asynchronously in a distributed
-cluster. An operator cannot assume or predict the exact time a tuple
-that it emitted will get consumed by a downstream operator. An operator
-also cannot predict the exact time when a tuple arrives from an upstream
-operator. The only guarantee is that the upstream operators are
-processing the current or a future window, i.e. the windowId of upstream
-operator is equals or exceeds its own windowId. Conversely the windowId
-of a downstream operator is less than or equals its own windowId. The
-end of a window operation, i.e. the API call to endWindow on an operator
-requires that all upstream operators have finished processing this
-window. This means that completion of processing a window propagates in
-a blocking fashion through an operator. Later sections provides more
-details on streams and data flow of tuples.
-
-
-
-Each operator has a unique name within the DAG as provided by the
-user. This is the name of the operator in the logical plan. The name of
-the operator in the physical plan is an integer assigned to it by STRAM.
-These integers are use the sequence from 1 to N, where N is total number
-of physically unique operators in the DAG.  Following the same rule,
-each partitioned instance of a logical operator has its own integer as
-an id. This id along with the Hadoop container name uniquely identifies
-the operator in the execution plan of the DAG. The logical names and the
-physical names are required for web service support. Operators can be
-accessed via both names. These same names are used while interacting
-with  dtcli to access an operator.
-Ideally these names should be self-descriptive. For example in Figure 1,
-the node named “Daily volume” has a physical identifier of 2.
-
-### Operator Interface
-
-Operator interface in a DAG consists of [ports](#h.ihv636)[,](#h.ihv636) [properties](#h.32hioqz)[,](#h.32hioqz) and
- [attributes](#h.41mghml)
-[.](#h.41mghml) Operators interact with other
-components of the DAG via ports. Functional behavior of the operators
-can be customized via parameters. Run time performance and physical
-instantiation is controlled by attributes. Ports and parameters are
-fields (variables) of the Operator class/object, while attributes are
-meta information that is attached to the operator object via an
-AttributeMap. An operator must have at least one port. Properties are
-optional. Attributes are provided by the platform and always have a
-default value that enables normal functioning of operators.
-
-#### Ports
-
-Ports are connection points by which an operator receives and
-emits tuples. These should be transient objects instantiated in the
-operator object, that implement particular interfaces. Ports should be
-transient as they contain no state. They have a pre-defined schema and
-can only be connected to other ports with the same schema. An input port
-needs to implement the interface  Operator.InputPort and
-interface Sink. A default
-implementation of these is provided by the abstract class DefaultInputPort. An output port needs to
-implement the interface  Operator.OutputPort. A default implementation
-of this is provided by the concrete class DefaultOutputPort. These two are a quick way to
-implement the above interfaces, but operator developers have the option
-of providing their own implementations.
-
-
-
-Here are examples of an input and an output port from the operator
-Sum.
-
-
-
-```java
-@InputPortFieldAnnotation(name = "data")
-public final transient DefaultInputPort<V> data = new DefaultInputPort<V>() {
-  @Override
-  public void process(V tuple)
-  {
-  	...
-  }
-}
-@OutputPortFieldAnnotation(optional=true)
-public final transient DefaultOutputPort<V> sum = new DefaultOutputPort<V>(){ … };
-```
-
-
-
-
-The process call is in the Sink interface. An emit on an output
-port is done via emit(tuple) call. For the above example it would be
-sum.emit(t), where the type of t is the generic parameter V.
-
-
-
-There is no limit on how many ports an operator can have. However
-any operator must have at least one port. An operator with only one port
-is called an Input Adapter if it has no input port and an Output Adapter
-if it has no output port. These are special operators needed to get/read
-data from outside system/source into the application, or push/write data
-into an outside system/sink. These could be in Hadoop or outside of
-Hadoop. These two operators are in essence gateways for the streaming
-application to communicate with systems outside the application.
-
-
-
-Port connectivity can be validated during compile time by adding
-PortFieldAnnotations shown above. By default all ports have to be
-connected, to allow a port to go unconnected, you need to add
-“optional=true” to the annotation.
-
-
-
-Attributes can be specified for ports that affect the runtime
-behavior. An example of an attribute is parallel partition that specifes
-a parallel computation flow per partition. It is described in detail in
-the [Parallel
-Partitions](#h.3vac5uf)[ ](#h.3vac5uf)section.
-Another example is queue capacity that specifies the buffer size for the
-port. Details of attributes are covered in  Operation and Installation Guide.
-
-#### Properties
-
-Properties are the abstractions by which functional behavior of an
-operator can be customized. They should be non-transient objects
-instantiated in the operator object. They need to be non-transient since
-they are part of the operator state and re-construction of the operator
-object from its checkpointed state must restore the operator to the
-desired state. Properties are optional, i.e. an operator may or may not
-have properties; they are part of user code and their values are not
-interpreted by the platform in any way.
-
-
-
-All non-serializable objects should be declared transient.
-Examples include sockets, session information, etc. These objects should
-be initialized during setup call, which is called every time the
-operator is initialized.
-
-#### Attributes
-
-Attributes are values assigned to the operators that impact
-run-time. This includes things like the number of partitions, at most
-once or at least once or exactly once recovery modes, etc. Attributes do
-not impact functionality of the operator. Users can change certain
-attributes in runtime. Users cannot add attributes to operators; they
-are pre-defined by the platform. They are interpreted by the platform
-and thus cannot be defined in user created code (like properties).
-Details of attributes are covered in  [Configuration Guide](configuration.md).
-
-### Operator State
-
-The state of an operator is defined as the data that it transfers
-from one window to a future window. Since the computing model of the
-platform is to treat windows like micro-batches, the operator state can
-be [checkpointed](#h.3mzq4wv)[ ](#h.3mzq4wv)every
-Nth window, or every T units of time, where T is significantly greater
-than the streaming window.  When an operator is checkpointed, the entire
-object is written to HDFS.  The larger the amount of state in an
-operator, the longer it takes to recover from a failure. A stateless
-operator can recover much quicker than a stateful one. The needed
-windows are preserved by the upstream buffer server and are used to
-recompute the lost windows, and also rebuild the buffer server in the
-current container.
-
-
-
-The distinction between Stateless and Stateful is based solely on
-the need to transfer data in the operator from one window to the next.
-The state of an operator is independent of the number of ports.
-
-#### Stateless
-
-A Stateless operator is defined as one where no data is needed to
-be kept at the end of every window. This means that all the computations
-of a window can be derived from all the tuples the operator receives
-within that window. This guarantees that the output of any window can be
-reconstructed by simply replaying the tuples that arrived in that
-window. Stateless operators are more efficient in terms of fault
-tolerance, and cost to achieve SLA.
-
-#### Stateful
-
-A Stateful operator is defined as one where data is needed to be
-stored at the end of a window for computations occurring in later
-window; a common example is the computation of a sum of values in the
-input tuples.
-
-### Operator API
-
-The Operator API consists of methods that operator developers may
-need to override. In this section we will discuss the Operator APIs from
-the point of view of an application developer. Knowledge of how an
-operator works internally is critical for writing an application. Those
-interested in the details should refer to  Malhar Operator Developer Guide.
-
-
-
-The APIs are available in three modes, namely Single Streaming
-Window, Sliding Application Window, and Aggregate Application Window.
-These are not mutually exclusive, i.e. an operator can use single
-streaming window as well as sliding application window. A physical
-instance of an operator is always processing tuples from a single
-window. The processing of tuples is guaranteed to be sequential, no
-matter which input port the tuples arrive on.
-
-
-
-In the later part of this section we will evaluate three common
-uses of streaming windows by applications. They have different
-characteristics and implications on optimization and recovery mechanisms
-(i.e. algorithm used to recover a node after outage) as discussed later
-in the section.
-
-#### Streaming Window
-
-Streaming window is atomic micro-batch computation period. The API
-methods relating to a streaming window are as follows
-
-
-
-```java
-public void process(<tuple_type> tuple) // Called on the input port on which the tuple arrives
-public void beginWindow(long windowId) // Called at the start of the window as soon as the first begin_window tuple arrives
-public void endWindow() // Called at the end of the window after end_window tuples arrive on all input ports
-public void setup(OperatorContext context) // Called once during initialization of the operator
-public void teardown() // Called once when the operator is being shutdown
-```
-
-
-A tuple can be emitted in any of the three streaming run-time
-calls, namely beginWindow, process, and endWindow but not in setup or
-teardown.
-
-#### Aggregate Application Window
-
-An operator with an aggregate window is stateful within the
-application window timeframe and possibly stateless at the end of that
-application window. An size of an aggregate application window is an
-operator attribute and is defined as a multiple of the streaming window
-size. The platform recognizes this attribute and optimizes the operator.
-The beginWindow, and endWindow calls are not invoked for those streaming
-windows that do not align with the application window. For example in
-case of streaming window of 0.5 second and application window of 5
-minute, an application window spans 600 streaming windows (5\*60\*2 =
-600). At the start of the sequence of these 600 atomic streaming
-windows, a beginWindow gets invoked, and at the end of these 600
-streaming windows an endWindow gets invoked. All the intermediate
-streaming windows do not invoke beginWindow or endWindow. Bookkeeping,
-node recovery, stats, UI, etc. continue to work off streaming windows.
-For example if operators are being checkpointed say on an average every
-30th window, then the above application window would have about 20
-checkpoints.
-
-#### Sliding Application Window
-
-A sliding window is computations that requires previous N
-streaming windows. After each streaming window the Nth past window is
-dropped and the new window is added to the computation. An operator with
-sliding window is a stateful operator at end of any window. The sliding
-window period is an attribute and is a multiple of streaming window. The
-platform recognizes this attribute and leverages it during bookkeeping.
-A sliding aggregate window with tolerance to data loss does not have a
-very high bookkeeping cost. The cost of all three recovery mechanisms,
- at most once (data loss tolerant),
-at least once (data loss
-intolerant), and exactly once (data
-loss intolerant and no extra computations) is same as recovery
-mechanisms based on streaming window. STRAM is not able to leverage this
-operator for any extra optimization.
-
-### Single vs Multi-Input Operator
-
-A single-input operator by definition has a single upstream
-operator, since there can only be one writing port for a stream.  If an
-operator has a single upstream operator, then the beginWindow on the
-upstream also blocks the beginWindow of the single-input operator. For
-an operator to start processing any window at least one upstream
-operator has to start processing that window. A multi-input operator
-reads from more than one upstream ports. Such an operator would start
-processing as soon as the first begin_window event arrives. However the
-window would not close (i.e. invoke endWindow) till all ports receive
-end_window events for that windowId. Thus the end of a window is a
-blocking event. As we saw earlier, a multi-input operator is also the
-point in the DAG where windows of all upstream operators are
-synchronized. The windows (atomic micro-batches) from a faster (or just
-ahead in processing) upstream operators are queued up till the slower
-upstream operator catches up. STRAM monitors such bottlenecks and takes
-corrective actions. The platform ensures minimal delay, i.e processing
-starts as long as at least one upstream operator has started
-processing.
-
-### Recovery Mechanisms
-
-Application developers can set any of the recovery mechanisms
-below to deal with node outage. In general, the cost of recovery depends
-on the state of the operator, while data integrity is dependant on the
-application. The mechanisms are per window as the platform treats
-windows as atomic compute units. Three recovery mechanisms are
-supported, namely
-
--   At-least-once: All atomic batches are processed at least once.
-    No data loss occurs.
--   At-most-once: All atomic batches are processed at most once.
-    Data loss is possible; this is the most efficient setting.
--   Exactly-once: All atomic batches are processed exactly once.
-    No data loss occurs; this is the least efficient setting since
-    additional work is needed to ensure proper semantics.
-
-At-least-once is the default. During a recovery event, the
-operator connects to the upstream buffer server and asks for windows to
-be replayed. At-least-once and exactly-once mechanisms start from its
-checkpointed state. At-most-once starts from the next begin-window
-event.
-
-
-
-Recovery mechanisms can be specified per Operator while writing
-the application as shown below.
-
-
-```java
-Operator o = dag.addOperator(“operator”, …);
-dag.setAttribute(o,  OperatorContext.PROCESSING_MODE,  ProcessingMode.AT_MOST_ONCE);
-```
-
-
-Also note that once an operator is attributed to AT_MOST_ONCE,
-all the operators downstream to it have to be AT_MOST_ONCE. The client
-will give appropriate warnings or errors if that’s not the case.
-
-
-
-Details are explained in the chapter on Fault Tolerance
-below[.](#h.2nusc19)
-
-Streams
---------------------
-
-A stream is a connector
-(edge) abstraction, and is a fundamental building block of the platform.
-A stream consists of tuples that flow from one port (called the
-output port) to one or more ports
-on other operators (called  input ports) another -- so note a potentially
-confusing aspect of this terminology: tuples enter a stream through its
-output port and leave via one or more input ports. A stream has the
-following characteristics
-
--   Tuples are always delivered in the same order in which they
-    were emitted.
--   Consists of a sequence of windows one after another. Each
-    window being a collection of in-order tuples.
--   A stream that connects two containers passes through a
-    buffer server.
--   All streams can be persisted (by default in HDFS).
--   Exactly one output port writes to the stream.
--   Can be read by one or more input ports.
--   Connects operators within an application, not outside
-    an application.
--   Has an unique name within an application.
--   Has attributes which act as hints to STRAM.
--   Streams have four modes, namely in-line, in-node, in-rack,
-    and other. Modes may be overruled (for example due to lack
-    of containers). They are defined as follows:
-
-    -   THREAD_LOCAL: In the same thread, uses thread
-        stack (intra-thread). This mode can only be used for a downstream
-        operator which has only one input port connected; also called
-        in-line.
-    -   CONTAINER_LOCAL: In the same container (intra-process); also
-        called in-container.
-    -   NODE_LOCAL: In the same Hadoop node (inter processes, skips
-        NIC); also called in-node.
-    -   RACK_LOCAL: On nodes in the same rack; also called
-        in-rack.
-    -   unspecified: No guarantee. Could be anywhere within the
-        cluster
-
-
-
-An example of a stream declaration is given below
-
-
-
-```java
-DAG dag = new DAG();
- …
-dag.addStream("views", viewAggregate.sum, cost.data).setLocality(CONTAINER_LOCAL); // A container local  stream
-dag.addStream(“clicks”, clickAggregate.sum, rev.data); // An example of unspecified locality
-```
-
-
-The platform guarantees in-order delivery of tuples in a stream.
-STRAM views each stream as collection of ordered windows. Since no tuple
-can exist outside a window, a replay of a stream consists of replay of a
-set of windows. When multiple input ports read the same stream, the
-execution plan of a stream ensures that each input port is logically not
-blocked by the reading of another input port. The schema of a stream is
-same as the schema of the tuple.
-
-
-
-In a stream all tuples emitted by an operator in a window belong
-to that window. A replay of this window would consists of an in-order
-replay of all the tuples. Thus the tuple order within a stream is
-guaranteed. However since an operator may receive multiple streams (for
-example an operator with two input ports), the order of arrival of two
-tuples belonging to different streams is not guaranteed. In general in
-an asynchronous distributed architecture this is expected. Thus the
-operator (specially one with multiple input ports) should not depend on
-the tuple order from two streams. One way to cope with this
-indeterminate order, if necessary, is to wait to get all the tuples of a
-window and emit results in endWindow call. All operator templates
-provided as part of  [standard operator template
-library](#h.3ep43zb) [ ](#h.3ep43zb)follow
-these principles.
-
-
-
-A logical stream gets partitioned into physical streams each
-connecting the partition to the upstream operator. If two different
-attributes are needed on the same stream, it should be split using
-StreamDuplicator operator.
-
-
-
-Modes of the streams are critical for performance. An in-line
-stream is the most optimal as it simply delivers the tuple as-is without
-serialization-deserialization. Streams should be marked
-container_local, specially in case where there is a large tuple volume
-between two operators which then on drops significantly. Since the
-setLocality call merely provides a hint, STRAM may ignore it. An In-node
-stream is not as efficient as an in-line one, but it is clearly better
-than going off-node since it still avoids the potential bottleneck of
-the network card.
-
-
-
-THREAD_LOCAL and CONTAINER_LOCAL streams do not use a buffer
-server as this stream is in a single process. The other two do.
-
-Validating an Application
---------------------------------------
-
-The platform provides various ways of validating the application
-specification and data input. An understanding of these checks is very
-important for an application developer since it affects productivity.
-Validation of an application is done in three phases, namely
-
-
-
-1.  Compile Time: Caught during application development, and is
-    most cost effective. These checks are mainly done on declarative
-    objects and leverages the Java compiler. An example is checking that
-    the schemas specified on all ports of a stream are
-    mutually compatible.
-2.  Initialization Time: When the application is being
-    initialized, before submitting to Hadoop. These checks are related
-    to configuration/context of an application, and are done by the
-    logical DAG builder implementation. An example is the checking that
-    all non-optional ports are connected to other ports.
-3.  Run Time: Validations done when the application is running.
-    This is the costliest of all checks. These are checks that can only
-    be done at runtime as they involve data. For example divide by 0
-    check as part of business logic.
-
-### Compile Time
-
-Compile time validations apply when an application is specified in
-Java code and include all checks that can be done by Java compiler in
-the development environment (including IDEs like NetBeans or Eclipse).
-Examples include
-
-1.  Schema Validation: The tuples on ports are POJO (plain old
-    java objects) and compiler checks to ensure that all the ports on a
-    stream have the same schema.
-2.  Stream Check: Single Output Port and at least one Input port
-    per stream. A stream can only have one output port writer. This is
-    part of the addStream api. This
-    check ensures that developers only connect one output port to
-    a stream. The same signature also ensures that there is at least one
-    input port for a stream
-3.  Naming: Compile time checks ensures that applications
-    components operators, streams are named
-
-### Initialization/Instantiation Time
-
-Initialization time validations include various checks that are
-done post compile, and before the application starts running in a
-cluster (or local mode). These are mainly configuration/contextual in
-nature. These checks are as critical to proper functionality of the
-application as the compile time validations.
-
-
-
-Examples include
-
--   [JavaBeans Validation](http://docs.oracle.com/javaee/6/tutorial/doc/gircz.html):
-    Examples include
-
-    -   @Max(): Value must be less than or equal to the number
-    -   @Min(): Value must be greater than or equal to the
-        number
-    -   @NotNull: The value of the field or property must not be
-        null
-    -   @Pattern(regexp = “....”): Value must match the regular
-        expression
-    -   Input port connectivity: By default, every non-optional input
-        port must be connected. A port can be declared optional by using an
-        annotation:     @InputPortFieldAnnotation(name = "...", optional
-        = true)
-    -   Output Port Connectivity: Similar. The annotation here is:    
-        @OutputPortFieldAnnotation(name = "...", optional = true)
-
--   Unique names in application scope: Operators, streams, must have
-    unique names.
--   Cycles in the dag: DAG cannot have a cycle.
--   Unique names in operator scope: Ports, properties, annotations
-    must have unique names.
--   One stream per port: A port can connect to only one stream.
-    This check applies to input as well as output ports even though an
-    output port can technically write to two streams. If you must have
-    two streams originating from a single output port, use  a streamDuplicator operator.
--   Application Window Period: Has to be an integral multiple the
-    streaming window period.
-
-### Run Time
-
-Run time checks are those that are done when the application is
-running. The real-time streaming platform provides rich run time error
-handling mechanisms. The checks are exclusively done by the application
-business logic, but the platform allows applications to count and audit
-these. Some of these features are in the process of development (backend
-and UI) and this section will be updated as they are developed. Upon
-completion examples will be added to  [demos](#h.upglbi) [t](#h.upglbi)o
-illustrate these.
-
-
-
-Error ports are output ports with error annotations. Since they
-are normal ports, they can be monitored and tuples counted, persisted
-and counts shown in the UI.
-
-------------------------------------------------------------------------
-
-
-
-
-
-Multi-Tenancy and Security
-=======================================
-
-Hadoop is a multi-tenant distributed operating system. Security is
-an intrinsic element of multi-tenancy as without it a cluster cannot be
-reasonably be shared among enterprise applications. Streaming
-applications follow all multi-tenancy security models used in Hadoop as
-they are native Hadoop applications. For details refer to the
-[Operation and Installation
-Guide](https://www.datatorrent.com/docs/guides/OperationandInstallationGuide.html)
-.
-
-Security
----------------------
-
-The platform includes Kerberos support. Both access points, namely
-STRAM and Bufferserver are secure. STRAM passes the token over to
-StreamingContainer, which then gives it to the Bufferserver. The most
-important aspect for an application developer is to note that STRAM is
-the single point of access to ensure security measures are taken by all
-components of the platform.
-
-Resource Limits
-----------------------------
-
-Hadoop enforces quotas on resources. This includes hard-disk (name
-space and total disk quota) as well as priority queues for schedulers.
-The platform uses Hadoop resource limits to manage a streaming
-application. In addition network I/O quotas can be enforced. An operator
-can be dynamically partitioned if it reaches its resource limits; these
-limits may be expressed in terms of throughput, latency, or just
-aggregate resource utilization of a container.
-
-
-
-
-
-------------------------------------------------------------------------
-
-
-
-
-
-Scalability and Partitioning
-=========================================
-
-Scalability is a foundational element of this platform and is a
-building block for an eco-system where big-data meets real-time.
-Enterprises need to continually meet SLA as data grows. Without the
-ability to scale as load grows, or new applications with higher loads
-come to fruition, enterprise grade SLA cannot be met. A big issue with
-the streaming application space is that, it is not just about high load,
-but also the fluctuations in it. There is no way to guarantee future
-load requirements and there is a big difference between high and low
-load within a day for the same feed. Traditional streaming platforms
-solve these two cases by simply throwing more hardware at the
-problem.
-
-
-
-Daily spikes are managed by ensuring enough hardware for peak
-load, which then idles during low load, and future needs are handled by
-a very costly re-architecture, or investing heavily in building a
-scalable distributed operating system. Another salient and often
-overlooked cost is the need to manage SLA -- let’s call it  buffer capacity. Since this means computing the
-peak load within required time, that translates to allocating enough
-resources over and above peak load as daily peaks fluctuate. For example
-an average peak load of 100 resource units (cpu and/or memory and/or
-network) may mean allocating about 200 resource units to be safe. A
-distributed cluster that cannot dynamically scale up and down, in effect
-pays buffer capacity per application. Another big aspect of streaming
-applications is that the load is not just ingestion rate, more often
-than not, the internal operators produce lot more events than the
-ingestion rate. For example a dimensional data (with, say  d dimensions) computation needs 2\*d -1 computations per ingested event. A lot
-of applications have over 10 dimensions, i.e over 1000 computations per
-incoming event and these need to be distributed across the cluster,
-thereby causing an explosion in the throughput (events/sec) that needs
-to be managed.
-
-
-
-The platform is designed to handle such cases at a very low cost.
-The platform scales linearly with Hadoop. If applications need more
-resources, the enterprise can simply add more commodity nodes to Hadoop
-without any downtime, and the Hadoop native platform will take care of
-the rest. If some nodes go bad, these can be removed without downtime.
-The daily peaks and valleys in the load are managed by the platform by
-dynamically scaling at the peak and then giving the resources back to
-Hadoop during low load. This means that a properly designed Hadoop
-cluster does several things for enterprises: (a) reduces the cost of
-hardware due to use of commodity hardware (b) shares buffer capacity
-across all applications as peaks of all applications may not align and
-(c) raises the average CPU usage on a 24x7 basis. As a general design
-this is similar to scale that a map-reduce application can deliver. In
-the following sections of this chapter we will see how this is
-done.
-
-Partitioning
--------------------------
-
-If all tuples sent through the stream(s) that are connected to the
-input port(s) of an operator in the DAG are received by a single
-physical instance of that operator, that operator can become a
-performance bottleneck. This leads to scalability issues when
-throughput, memory, or CPU needs exceed the processing capacity of that
-single instance.
-
-
-
-To address the problem, the platform offers the capability to
-partition the inflow of data so that it is divided across multiple
-physical instances of a logical operator in the DAG. There are two
-functional ways to partition
-
--   Load balance: Incoming load is simply partitioned
-    into stream(s) that go to separate instances of physical operators
-    and scalability is achieved via adding more physical operators. Each
-    tuple is sent to physical operator (partition) based on a
-    round-robin or other similar algorithm. This scheme scales linearly.
-    A lot of key based computations can load balance in the platform due
-    to the ability to insert  Unifiers. For many computations, the
-    endWindow and Unifier setup is similar to the combiner and reducer
-    mechanism in a Map-Reduce computation.
--   Sticky Key: The key assertion is that distribution of tuples
-    are sticky, i.e the data with
-    same key will always be processed by the same physical operator, no
-    matter how many times it is sent through the stream. This stickiness
-    will continue even if the number of partitions grows dynamically and
-    can eventually be leveraged for advanced features like
-    bucket testing. How this is accomplished and what is required to
-    develop compliant operators will be explained below.
-
-
-
-We plan to add more partitioning mechanisms proactively to the
-platform over time as needed by emerging usage patterns. The aim is to
-allow enterprises to be able to focus on their business logic, and
-significantly reduce the cost of operability. As an enabling technology
-for managing high loads, this platform provides enterprises with a
-significant innovative edge. Scalability and Partitioning is a
-foundational building block for this platform.
-
-### Sticky Partition vs Round Robin
-
-As noted above, partitioning via sticky key is data aware but
-round-robin partitioning is not. An example for non-sticky load
-balancing would be round robin distribution over multiple instances,
-where for example a tuple stream of  A, A,
-A with 3 physical operator
-instances would result in processing of a single A by each of the instances, In contrast, sticky
-partitioning means that exactly one instance of the operators will
-process all of the  Atuples if they
-fall into the same bucket, while B
-may be processed by another operator. Data aware mapping of
-tuples to partitions (similar to distributed hash table) is accomplished
-via Stream Codecs. In later sections we would show how these two
-approaches can be used in combination.
-
-### Stream Codec
-
-The platform does not make assumptions about the tuple
-type, it could be any Java object. The operator developer knows what
-tuple type an input port expects and is capable of processing. Each
-input port has a stream codec  associated thatdefines how data is serialized when transmitted over a socket
-stream; it also defines another
-function that computes the partition hash key for the tuple. The engine
-uses that key to determine which physical instance(s)  (for a
-partitioned operator) receive that  tuple. For this to work, consistent hashing is required.
-The default codec uses the Java Object\#hashCode function, which is
-sufficient for basic types such as Integer, String etc. It will also
-work with custom tuple classes as long as they implement hashCode
-appropriately. Reliance on hashCode may not work when generic containers
-are used that do not hash the actual data, such as standard collection
-classes (HashMap etc.), in which case a custom stream codec must be
-assigned to the input port.
-
-### Static Partitioning
-
-DAG designers can specify at design time how they would like
-certain operators to be partitioned. STRAM then instantiates the DAG
-with the physical plan which adheres to the partitioning scheme defined
-by the design. This plan is the initial partition of the application. In
-other words, Static Partitioning is used to tell STRAM to compute the
-physical DAG from a logical DAG once, without taking into consideration
-runtime states or loads of various operators.
-
-### Dynamic Partitioning
-
-In streaming applications the load changes during the day, thus
-creating situations where the number of partitioned operator instances
-needs to adjust dynamically. The load can be measured in terms of
-processing within the DAG based on throughput, or latency, or
-considerations in external system components (time based etc.) that the
-platform may not be aware of. Whatever the trigger, the resource
-requirement for the current processing needs to be adjusted at run-time.
-The platform may detect that operator instances are over or under
-utilized and may need to dynamically adjust the number of instances on
-the fly. More instances of a logical operator may be required (partition
-split) or underutilized operator instances may need decommissioning
-(partition merge). We refer to either of the changes as dynamic
-partitioning. The default partitioning scheme supports split and merge
-of partitions, but 

<TRUNCATED>


[04/11] incubator-apex-core git commit: Migrating docs

Posted by th...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/application_packages.md
----------------------------------------------------------------------
diff --git a/application_packages.md b/application_packages.md
deleted file mode 100644
index 521779a..0000000
--- a/application_packages.md
+++ /dev/null
@@ -1,669 +0,0 @@
-Apache Apex Application Packages
-================================
-
-An Apache Apex Application Package is a zip file that contains all the
-necessary files to launch an application in Apache Apex. It is the
-standard way for assembling and sharing an Apache Apex application.
-
-# Requirements
-
-You will need have the following installed:
-
-1. Apache Maven 3.0 or later (for assembling the App Package)
-2. Apache Apex 3.0.0 or later (for launching the App Package in your cluster)
-
-# Creating Your First Apex App Package
-
-You can create an Apex Application Package using your Linux command
-line, or using your favorite IDE.
-
-## Using Command Line
-
-First, change to the directory where you put your projects, and create
-an Apex application project using Maven by running the following
-command.  Replace "com.example", "mydtapp" and "1.0-SNAPSHOT" with the
-appropriate values (make sure this is all on one line):
-
-    $ mvn archetype:generate \
-     -DarchetypeGroupId=org.apache.apex \
-     -DarchetypeArtifactId=apex-app-archetype -DarchetypeVersion=3.2.0-incubating \
-     -DgroupId=com.example -Dpackage=com.example.mydtapp -DartifactId=mydtapp \
-     -Dversion=1.0-SNAPSHOT
-
-This creates a Maven project named "mydtapp". Open it with your favorite
-IDE (e.g. NetBeans, Eclipse, IntelliJ IDEA). In the project, there is a
-sample DAG that generates a number of tuples with a random number and
-prints out "hello world" and the random number in the tuples.  The code
-that builds the DAG is in
-src/main/java/com/example/mydtapp/Application.java, and the code that
-runs the unit test for the DAG is in
-src/test/java/com/example/mydtapp/ApplicationTest.java. Try it out by
-running the following command:
-
-    $cd mydtapp; mvn package
-
-This builds the App Package runs the unit test of the DAG.  You should
-be getting test output similar to this:
-
-```
- -------------------------------------------------------
-  TESTS
- -------------------------------------------------------
-
- Running com.example.mydtapp.ApplicationTest
- hello world: 0.8015370953286478
- hello world: 0.9785359225545481
- hello world: 0.6322611586644047
- hello world: 0.8460953663451775
- hello world: 0.5719372906929072
- hello world: 0.6361174312337172
- hello world: 0.14873007534816318
- hello world: 0.8866986277418261
- hello world: 0.6346526809866057
- hello world: 0.48587295703904465
- hello world: 0.6436832429676687
-
- ...
-
- Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 11.863
- sec
-
- Results :
-
- Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
-```
-
-The "mvn package" command creates the App Package file in target
-directory as target/mydtapp-1.0-SNAPSHOT.apa. You will be able to use
-that App Package file to launch this sample application in your actual
-Apex installation.
-
-## Using IDE
-
-Alternatively, you can do the above steps all within your IDE.  For
-example, in NetBeans, select File -\> New Project.  Then choose “Maven”
-and “Project from Archetype” in the dialog box, as shown.
-
-![](images/AppPackage/ApplicationPackages.html-image00.png)
-
-Then fill the Group ID, Artifact ID, Version and Repository entries as shown below.
-
-![](images/AppPackage/ApplicationPackages.html-image02.png)
-
-Group ID: org.apache.apex
-Artifact ID: apex-app-archetype
-Version: 3.2.0-incubating (or any later version)
-
-Press Next and fill out the rest of the required information. For
-example:
-
-![](images/AppPackage/ApplicationPackages.html-image01.png)
-
-Click Finish, and now you have created your own Apache Apex App Package
-project, with a default unit test.  You can run the unit test, make code
-changes or make dependency changes within your IDE.  The procedure for
-other IDEs, like Eclipse or IntelliJ, is similar.
-
-# Writing Your Own App Package
-
-
-Please refer to the [Creating Apps](create.md) on the basics on how to write an Apache Apex application.  In your AppPackage project, you can add custom operators (refer to [Operator Development Guide](https://www.datatorrent.com/docs/guides/OperatorDeveloperGuide.html)), project dependencies, default and required configuration properties, pre-set configurations and other metadata.
-
-## Adding (and removing) project dependencies
-
-Under the project, you can add project dependencies in pom.xml, or do it
-through your IDE.  Here’s the section that describes the dependencies in
-the default pom.xml:
-```
-  <dependencies>
-    <!-- add your dependencies here -->
-    <dependency>
-      <groupId>org.apache.apex</groupId>
-      <artifactId>malhar-library</artifactId>
-      <version>${apex.version}</version>
-      <!--
-           If you know your application do not need the transitive dependencies that are pulled in by malhar-library,
-           Uncomment the following to reduce the size of your app package.
-      -->
-      <!--
-      <exclusions>
-        <exclusion>
-          <groupId>*</groupId>
-          <artifactId>*</artifactId>
-        </exclusion>
-      </exclusions>
-      -->
-    </dependency>
-    <dependency>
-      <groupId>org.apache.apex</groupId>
-      <artifactId>apex-engine</artifactId>
-      <version>${apex.version}</version>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>4.10</version>
-      <scope>test</scope>
-    </dependency>
-  </dependencies>
-```
-
-By default, as shown above, the default dependencies include
-malhar-library in compile scope, dt-engine in provided scope, and junit
-in test scope.  Do not remove these three dependencies since they are
-necessary for any Apex application.  You can, however, exclude
-transitive dependencies from malhar-library to reduce the size of your
-App Package, provided that none of the operators in malhar-library that
-need the transitive dependencies will be used in your application.
-
-In the sample application, it is safe to remove the transitive
-dependencies from malhar-library, by uncommenting the "exclusions"
-section.  It will reduce the size of the sample App Package from 8MB to
-700KB.
-
-Note that if we exclude \*, in some versions of Maven, you may get
-warnings similar to the following:
-
-```
-
- [WARNING] 'dependencies.dependency.exclusions.exclusion.groupId' for
- org.apache.apex:malhar-library:jar with value '*' does not match a
- valid id pattern.
-
- [WARNING]
- [WARNING] It is highly recommended to fix these problems because they
- threaten the stability of your build.
- [WARNING]
- [WARNING] For this reason, future Maven versions might no longer support
- building such malformed projects.
- [WARNING]
-
-```
-This is a bug in early versions of Maven 3.  The dependency exclusion is
-still valid and it is safe to ignore these warnings.
-
-## Application Configuration
-
-A configuration file can be used to configure an application.  Different
-kinds of configuration parameters can be specified. They are application
-attributes, operator attributes and properties, port attributes, stream
-properties and application specific properties. They are all specified
-as name value pairs, in XML format, like the following.
-
-```
-<?xml version="1.0"?>
-<configuration>
-  <property>
-    <name>some_name_1</name>
-    <value>some_default_value</value>
-  </property>
-  <property>
-    <name>some_name_2</name>
-    <value>some_default_value</value>
-  </property>
-</configuration>
-```
-
-## Application attributes
-
-Application attributes are used to specify the platform behavior for the
-application. They can be specified using the parameter
-```dt.attr.<attribute>```. The prefix “dt” is a constant, “attr” is a
-constant denoting an attribute is being specified and ```<attribute>```
-specifies the name of the attribute. Below is an example snippet setting
-the streaming windows size of the application to be 1000 milliseconds.
-
-```
-  <property>
-     <name>dt.attr.STREAMING_WINDOW_SIZE_MILLIS</name>
-     <value>1000</value>
-  </property>
-```
-
-The name tag specifies the attribute and value tag specifies the
-attribute value. The name of the attribute is a JAVA constant name
-identifying the attribute. The constants are defined in
-com.datatorrent.api.Context.DAGContext and the different attributes can
-be specified in the format described above.
-
-## Operator attributes
-
-Operator attributes are used to specify the platform behavior for the
-operator. They can be specified using the parameter
-```dt.operator.<operator-name>.attr.<attribute>```. The prefix “dt” is a
-constant, “operator” is a constant denoting that an operator is being
-specified, ```<operator-name>``` denotes the name of the operator, “attr” is
-the constant denoting that an attribute is being specified and
-```<attribute>``` is the name of the attribute. The operator name is the
-same name that is specified when the operator is added to the DAG using
-the addOperator method. An example illustrating the specification is
-shown below. It specifies the number of streaming windows for one
-application window of an operator named “input” to be 10
-
-```
-<property>
-  <name>dt.operator.input.attr.APPLICATION_WINDOW_COUNT</name>
-  <value>10</value>
-</property>
-```
-
-The name tag specifies the attribute and value tag specifies the
-attribute value. The name of the attribute is a JAVA constant name
-identifying the attribute. The constants are defined in
-com.datatorrent.api.Context.OperatorContext and the different attributes
-can be specified in the format described above.
-
-## Operator properties
-
-Operators can be configured using operator specific properties. The
-properties can be specified using the parameter
-```dt.operator.<operator-name>.prop.<property-name>```. The difference
-between this and the operator attribute specification described above is
-that the keyword “prop” is used to denote that it is a property and
-```<property-name>``` specifies the property name.  An example illustrating
-this is specified below. It specifies the property “hostname” of the
-redis server for a “redis” output operator.
-
-```
-  <property>
-    <name>dt.operator.redis.prop.host</name>
-    <value>127.0.0.1</value>
-  </property>
-```
-
-The name tag specifies the property and the value specifies the property
-value. The property name is converted to a setter method which is called
-on the actual operator. The method name is composed by appending the
-word “set” and the property name with the first character of the name
-capitalized. In the above example the setter method would become
-setHost. The method is called using JAVA reflection and the property
-value is passed as an argument. In the above example the method setHost
-will be called on the “redis” operator with “127.0.0.1” as the argument.
-
-## Port attributes
-Port attributes are used to specify the platform behavior for input and
-output ports. They can be specified using the parameter ```dt.operator.<operator-name>.inputport.<port-name>.attr.<attribute>```
-for input port and ```dt.operator.<operator-name>.outputport.<port-name>.attr.<attribute>```
-for output port. The keyword “inputport” is used to denote an input port
-and “outputport” to denote an output port. The rest of the specification
-follows the conventions described in other specifications above. An
-example illustrating this is specified below. It specifies the queue
-capacity for an input port named “input” of an operator named “range” to
-be 4k.
-
-```
-<property>
-  <name>dt.operator.range.inputport.input.attr.QUEUE_CAPACITY</name>
-  <value>4000</value>
-</property>
-```
-
-The name tag specifies the attribute and value tag specifies the
-attribute value. The name of the attribute is a JAVA constant name
-identifying the attribute. The constants are defined in
-com.datatorrent.api.Context.PortContext and the different attributes can
-be specified in the format described above.
-
-The attributes for an output port can also be specified in a similar way
-as described above with a change that keyword “outputport” is used
-instead of “intputport”. A generic keyword “port” can be used to specify
-either an input or an output port. It is useful in the wildcard
-specification described below.
-
-## Stream properties
-
-Streams can be configured using stream properties. The properties can be
-specified using the parameter
-```dt.stream.<stream-name>.prop.<property-name>```  The constant “stream”
-specifies that it is a stream, ```<stream-name>``` specifies the name of the
-stream and ```<property-name>``` the name of the property. The name of the
-stream is the same name that is passed when the stream is added to the
-DAG using the addStream method. An example illustrating the
-specification is shown below. It sets the locality of the stream named
-“stream1” to container local indicating that the operators the stream is
-connecting be run in the same container.
-
-```
-  <property>
-    <name>dt.stream.stream1.prop.locality</name>
-    <value>CONTAINER_LOCAL</value>
-  </property>
-```
-
-The property name is converted into a set method on the stream in the
-same way as described in operator properties section above. In this case
-the method would be setLocality and it will be called in the stream
-“stream1” with the value as the argument.
-
-Along with the above system defined parameters, the applications can
-define their own specific parameters they can be specified in the
-configuration file. The only condition is that the names of these
-parameters don’t conflict with the system defined parameters or similar
-application parameters defined by other applications. To this end, it is
-recommended that the application parameters have the format
-```<full-application-class-name>.<param-name>.``` The
-full-application-class-name is the full JAVA class name of the
-application including the package path and param-name is the name of the
-parameter within the application. The application will still have to
-still read the parameter in using the configuration API of the
-configuration object that is passed in populateDAG.
-
-##  Wildcards
-
-Wildcards and regular expressions can be used in place of names to
-specify a group for applications, operators, ports or streams. For
-example, to specify an attribute for all ports of an operator it can be
-done as follows
-```
-<property>
-  <name>dt.operator.range.port.*.attr.QUEUE_CAPACITY</name>
-  <value>4000</value>
-</property>
-```
-
-The wildcard “\*” was used instead of the name of the port. Wildcard can
-also be used for operator name, stream name or application name. Regular
-expressions can also be used for names to specify attributes or
-properties for a specific set.
-
-## Adding configuration properties
-
-It is common for applications to require configuration parameters to
-run.  For example, the address and port of the database, the location of
-a file for ingestion, etc.  You can specify them in
-src/main/resources/META-INF/properties.xml under the App Package
-project. The properties.xml may look like:
-
-```
-<?xml version="1.0"?>
-<configuration>
-  <property>
-    <name>some_name_1</name>
-  </property>
-  <property>
-    <name>some_name_2</name>
-    <value>some_default_value</value>
-  </property>
-</configuration>
-```
-
-The name of an application-specific property takes the form of:
-
-```dt.operator.{opName}.prop.{propName} ```
-
-The first represents the property with name propName of operator opName.
- Or you can set the application name at run time by setting this
-property:
-
-        dt.attr.APPLICATION_NAME
-
-There are also other properties that can be set.  For details on
-properties, refer to the [Operation and Installation Guide](https://www.datatorrent.com/docs/guides/OperationandInstallationGuide.html).
-
-In this example, property some_name_1 is a required property which
-must be set at launch time, or it must be set by a pre-set configuration
-(see next section).  Property some\_name\_2 is a property that is
-assigned with value some\_default\_value unless it is overridden at
-launch time.
-
-## Adding pre-set configurations
-
-
-At build time, you can add pre-set configurations to the App Package by
-adding configuration XML files under ```src/site/conf/<conf>.xml```in your
-project.  You can then specify which configuration to use at launch
-time.  The configuration XML is of the same format of the properties.xml
-file.
-
-## Application-specific properties file
-
-You can also specify properties.xml per application in the application
-package.  Just create a file with the name properties-{appName}.xml and
-it will be picked up when you launch the application with the specified
-name within the application package.  In short:
-
-  properties.xml: Properties that are global to the Configuration
-Package
-
-  properties-{appName}.xml: Properties that are specific when launching
-an application with the specified appName.
-
-## Properties source precedence
-
-If properties with the same key appear in multiple sources (e.g. from
-app package default configuration as META-INF/properties.xml, from app
-package configuration in the conf directory, from launch time defines,
-etc), the precedence of sources, from highest to lowest, is as follows:
-
-1. Launch time defines (using -D option in CLI, or the POST payload
-    with the Gateway REST API’s launch call)
-2. Launch time specified configuration file in file system (using -conf
-    option in CLI)
-3. Launch time specified package configuration (using -apconf option in
-    CLI or the conf={confname} with Gateway REST API’s launch call)
-4. Configuration from \$HOME/.dt/dt-site.xml
-5. Application defaults within the package as
-    META-INF/properties-{appname}.xml
-6. Package defaults as META-INF/properties.xml
-7. dt-site.xml in local DT installation
-8. dt-site.xml stored in HDFS
-
-## Other meta-data
-
-In a Apex App Package project, the pom.xml file contains a
-section that looks like:
-
-```
-<properties>
-  <apex.version>3.2.0-incubating</apex.version>
-  <apex.apppackage.classpath\>lib*.jar</apex.apppackage.classpath>
-</properties>
-```
-apex.version is the Apache Apex version that are to be used
-with this Application Package.
-
-apex.apppackage.classpath is the classpath that is used when
-launching the application in the Application Package.  The default is
-lib/\*.jar, where lib is where all the dependency jars are kept within
-the Application Package.  One reason to change this field is when your
-Application Package needs the classpath in a specific order.
-
-## Logging configuration
-
-Just like other Java projects, you can change the logging configuration
-by having your log4j.properties under src/main/resources.  For example,
-if you have the following in src/main/resources/log4j.properties:
-```
- log4j.rootLogger=WARN,CONSOLE
- log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
- log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
- log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} [%t] %-5p
- %c{2} %M - %m%n
-```
-
-The root logger’s level is set to WARN and the output is set to the console (stdout).
-
-Note that by default from project created from the maven archetype,
-there is already a log4j.properties file under src/test/resources and
-that file is only used for the unit test.
-
-# Zip Structure of Application Package
-
-
-Apache Apex Application Package files are zip files.  You can examine the content of any Application Package by using unzip -t on your Linux command line.
-
-There are four top level directories in an Application Package:
-
-1. "app" contains the jar files of the DAG code and any custom operators.
-2. "lib" contains all dependency jars
-3. "conf" contains all the pre-set configuration XML files.
-4. "META-INF" contains the MANIFEST.MF file and the properties.xml file.
-5. “resources” contains other files that are to be served by the Gateway on behalf of the app package.
-
-
-# Managing Application Packages Through DT Gateway
-
-The DT Gateway provides storing and retrieving Application Packages to
-and from your distributed file system, e.g. HDFS.
-
-## Storing an Application Package
-
-You can store your Application Packages through DT Gateway using this
-REST call:
-
-```
- POST /ws/v2/appPackages
-```
-
-The payload is the raw content of your Application Package.  For
-example, you can issue this request using curl on your Linux command
-line like this, assuming your DT Gateway is accepting requests at
-localhost:9090:
-
-```
-$ curl -XPOST -T <app-package-file> http://localhost:9090/ws/v2/appPackages
-```
-
-## Getting Meta Information on Application Packages
-
-
-You can get the meta information on Application Packages stored through
-DT Gateway using this call.  The information includes the logical plan
-of each application within the Application Package.
-
-```
- GET /ws/v2/appPackages/{owner}/{pkgName}/{pkgVersion}
-```
-
-## Getting Available Operators In Application Package
-
-You can get the list of available operators in the Application Package
-using this call.
-
-```
-GET /ws/v2/appPackages/{owner}/{pkgName}/{pkgVersion}/operators?parent={parent}
-```
-
-The parent parameter is optional.  If given, parent should be the fully
-qualified class name.  It will only return operators that derive from
-that class or interface. For example, if parent is
-com.datatorrent.api.InputOperator, this call will only return input
-operators provided by the Application Package.
-
-## Getting Properties of Operators in Application Package
-
-You can get the list of properties of any operator in the Application
-Package using this call.
-
-```
-GET  /ws/v2/appPackages/{owner}/{pkgName}/{pkgVersion}/operators/{className}
-```
-
-## Getting List of Pre-Set Configurations in Application Package
-
-You can get a list of pre-set configurations within the Application
-Package using this call.
-
-```
-GET /ws/v2/appPackages/{owner}/{pkgName}/{packageVersion}/configs
-```
-
-You can also get the content of a specific pre-set configuration within
-the Application Package.
-
-```
- GET /ws/v2/appPackages/{owner}/{pkgName}/{pkgVersion}/configs/{configName}
-```
-
-## Changing Pre-Set Configurations in Application Package
-
-You can create or replace pre-set configurations within the Application
-Package
-```
- PUT   /ws/v2/appPackages/{owner}/{pkgName}/{pkgVersion}/configs/{configName}
-```
-The payload of this PUT call is the XML file that represents the pre-set configuration.  The Content-Type of the payload is "application/xml" and you can delete a pre-set configuration within the Application Package.
-```
- DELETE /ws/v2/appPackages/{owner}/{pkgName}/{pkgVersion}/configs/{configName}
-```
-
-## Retrieving an Application Package
-
-You can download the Application Package file.  This Application Package
-is not necessarily the same file as the one that was originally uploaded
-since the pre-set configurations may have been modified.
-
-```
- GET /ws/v2/appPackages/{owner}/{pkgName}/{pkgVersion}/download
-```
-
-## Launching an Application Package
-
-You can launch an application within an Application Package.
-```
-POST /ws/v2/appPackages/{owner}/{pkgName}/{pkgVersion}/applications/{appName}/launch?config={configName}
-```
-
-The config parameter is optional.  If given, it must be one of the
-pre-set configuration within the given Application Package.  The
-Content-Type of the payload of the POST request is "application/json"
-and should contain the properties to be launched with the application.
- It is of the form:
-
-```
- {"property-name":"property-value", ... }
-```
-
-Here is an example of launching an application through curl:
-
-```
- $ curl -XPOST -d'{"dt.operator.console.prop.stringFormat":"xyz %s"}'
- http://localhost:9090/ws/v2/appPackages/dtadmin/mydtapp/1.0-SNAPSHOT/app
- lications/MyFirstApplication/launch
-```
-
-Please refer to the [Gateway API reference](https://www.google.com/url?q=https://www.datatorrent.com/docs/guides/DTGatewayAPISpecification.html&sa=D&usg=AFQjCNEWfN7-e7fd6MoWZjmJUE3GW7UwdQ) for the complete specification of the REST API.
-
-# Examining and Launching Application Packages Through Apex CLI
-
-If you are working with Application Packages in the local filesystem and
-do not want to deal with dtGateway, you can use the Apex Command Line Interface (dtcli).  Please refer to the [Gateway API](dtgateway_api.md)
-to see samples for these commands.
-
-## Getting Application Package Meta Information
-
-You can get the meta information about the Application Package using
-this Apex CLI command.
-
-```
- dt> get-app-package-info <app-package-file>
-```
-
-## Getting Available Operators In Application Package
-
-You can get the list of available operators in the Application Package
-using this command.
-
-```
- dt> get-app-package-operators <app-package-file> <package-prefix>
- [parent-class]
-```
-
-## Getting Properties of Operators in Application Package
-
-You can get the list of properties of any operator in the Application
-Package using this command.
-
- dt> get-app-package-operator-properties <app-package-file> <operator-class>
-
-
-## Launching an Application Package
-
-You can launch an application within an Application Package.
-```
-dt> launch [-D property-name=property-value, ...] [-conf config-name]
- [-apconf config-file-within-app-package] <app-package-file>
- [matching-app-name]
-```
-Note that -conf expects a configuration file in the file system, while -apconf expects a configuration file within the app package.

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/autometrics.md
----------------------------------------------------------------------
diff --git a/autometrics.md b/autometrics.md
deleted file mode 100644
index f6000e8..0000000
--- a/autometrics.md
+++ /dev/null
@@ -1,311 +0,0 @@
-Apache Apex AutoMetrics
-=======================
-
-# Introduction
-Metrics collect various statistical information about a process which can be very useful for diagnosis. Auto Metrics in Apex can help monitor operators in a running application.  The goal of *AutoMetric* API is to enable operator developer to define relevant metrics for an operator in a simple way which the platform collects and reports automatically.
-
-# Specifying AutoMetrics in an Operator
-An *AutoMetric* can be any object. It can be of a primitive type - int, long, etc. or a complex one. A field or a `get` method in an operator can be annotated with `@AutoMetric` to specify that its value is a metric. After every application end window, the platform collects the values of these fields/methods in a map and sends it to application master.
-
-```java
-public class LineReceiver extends BaseOperator
-{
- @AutoMetric
- long length;
-
- @AutoMetric
- long count;
-
- public final transient DefaultInputPort<String> input = new DefaultInputPort<String>()
- {
-   @Override
-   public void process(String s)
-   {
-     length += s.length();
-     count++;
-   }
- };
-
- @Override
- public void beginWindow(long windowId)
- {
-   length = 0;
-   count = 0;
- }
-}
-```
-
-There are 2 auto-metrics declared in the `LineReceiver`. At the end of each application window, the platform will send a map with 2 entries - `[(length, 100), (count, 10)]` to the application master.
-
-# Aggregating AutoMetrics across Partitions
-When an operator is partitioned, it is useful to aggregate the values of auto-metrics across all its partitions every window to get a logical view of these metrics. The application master performs these aggregations using metrics aggregators.
-
-The AutoMetric API helps to achieve this by providing an interface for writing aggregators- `AutoMetric.Aggregator`. Any implementation of `AutoMetric.Aggregator` can be set as an operator attribute - `METRICS_AGGREGATOR` for a particular operator which in turn is used for aggregating physical metrics.
-
-## Default aggregators
-[`MetricsAggregator`](https://github.com/apache/incubator-apex-core/blob/devel-3/common/src/main/java/com/datatorrent/common/metric/MetricsAggregator.java) is a simple implementation of `AutoMetric.Aggregator` that platform uses as a default for summing up primitive types - int, long, float and double.
-
-`MetricsAggregator` is just a collection of `SingleMetricAggregator`s. There are multiple implementations of `SingleMetricAggregator` that perform sum, min, max, avg which are present in Apex core and Apex malhar.
-
-For the `LineReceiver` operator, the application developer need not specify any aggregator. The platform will automatically inject an instance of `MetricsAggregator` that contains two `LongSumAggregator`s - one for `length` and one for `count`. This aggregator will report sum of length and sum of count across all the partitions of `LineReceiver`.
-
-
-## Building custom aggregators
-Platform cannot perform any meaningful aggregations for non-numeric metrics. In such cases, the operator or application developer can write custom aggregators. Let’s say, if the `LineReceiver` was modified to have a complex metric as shown below.
-
-```java
-public class AnotherLineReceiver extends BaseOperator
-{
-  @AutoMetric
-  final LineMetrics lineMetrics = new LineMetrics();
-
-  public final transient DefaultInputPort<String> input = new DefaultInputPort<String>()
-  {
-    @Override
-    public void process(String s)
-    {
-      lineMetrics.length += s.length();
-      lineMetrics.count++;
-    }
-  };
-
-  @Override
-  public void beginWindow(long windowId)
-  {
-    lineMetrics.length = 0;
-    lineMetrics.count = 0;
-  }
-
-  public static class LineMetrics implements Serializable
-  {
-    long length;
-    long count;
-
-    private static final long serialVersionUID = 201511041908L;
-  }
-}
-```
-
-Below is a custom aggregator that can calculate average line length across all partitions of `AnotherLineReceiver`.
-
-```java
-public class AvgLineLengthAggregator implements AutoMetric.Aggregator
-{
-
-  Map<String, Object> result = Maps.newHashMap();
-
-  @Override
-  public Map<String, Object> aggregate(long l, Collection<AutoMetric.PhysicalMetricsContext> collection)
-  {
-    long totalLength = 0;
-    long totalCount = 0;
-    for (AutoMetric.PhysicalMetricsContext pmc : collection) {
-      AnotherLineReceiver.LineMetrics lm = (AnotherLineReceiver.LineMetrics)pmc.getMetrics().get("lineMetrics");
-      totalLength += lm.length;
-      totalCount += lm.count;
-    }
-    result.put("avgLineLength", totalLength/totalCount);
-    return result;
-  }
-}
-```
-An instance of above aggregator can be specified as the `METRIC_AGGREGATOR` for `AnotherLineReceiver` while creating the DAG as shown below.
-
-```java
-  @Override
-  public void populateDAG(DAG dag, Configuration configuration)
-  {
-    ...
-    AnotherLineReceiver lineReceiver = dag.addOperator("LineReceiver", new AnotherLineReceiver());
-    dag.setAttribute(lineReceiver, Context.OperatorContext.METRICS_AGGREGATOR, new AvgLineLengthAggregator());
-    ...
-  }
-```
-
-# Retrieving AutoMetrics
-The Gateway REST API provides a way to retrieve the latest AutoMetrics for each logical operator.  For example:
-
-```
-GET /ws/v2/applications/{appid}/logicalPlan/operators/{opName}
-{
-    ...
-    "autoMetrics": {
-       "count": "71314",
-       "length": "27780706"
-    },
-    "className": "com.datatorrent.autometric.LineReceiver",
-    ...
-}
-```
-
-# System Metrics
-System metrics are standard operator metrics provided by the system.  Examples include:
-
-- processed tuples per second
-- emitted tuples per second
-- total tuples processed
-- total tuples emitted
-- latency
-- CPU percentage
-- failure count
-- checkpoint elapsed time
-
-The Gateway REST API provides a way to retrieve the latest values for all of the above for each of the logical operators in the application.
-
-```
-GET /ws/v2/applications/{appid}/logicalPlan/operators/{opName}
-{
-    ...
-    "cpuPercentageMA": "{cpuPercentageMA}",
-    "failureCount": "{failureCount}",
-    "latencyMA": "{latencyMA}",  
-    "totalTuplesEmitted": "{totalTuplesEmitted}",
-    "totalTuplesProcessed": "{totalTuplesProcessed}",
-    "tuplesEmittedPSMA": "{tuplesEmittedPSMA}",
-    "tuplesProcessedPSMA": "{tuplesProcessedPSMA}",
-    ...
-}
-```
-
-However, just like AutoMetrics, the Gateway only provides the latest metrics.  For historical metrics, we will need the help of App Data Tracker.
-
-# App Data Tracker
-As discussed above, STRAM aggregates the AutoMetrics from physical operators (partitions) to something that makes sense in one logical operator.  It pushes the aggregated AutoMetrics values using Websocket to the Gateway at every second along with system metrics for each operator.  Gateway relays the information to an application called App Data Tracker.  It is another Apex application that runs in the background and further aggregates the incoming values by time bucket and stores the values in HDHT.  It also allows the outside to retrieve the aggregated AutoMetrics and system metrics through websocket interface.
-
-![AppDataTracker](images/autometrics/adt.png)
-
-App Data Tracker is enabled by having these properties in dt-site.xml:
-
-```xml
-<property>
-  <name>dt.appDataTracker.enable</name>
-  <value>true</value>
-</property>
-<property>
-  <name>dt.appDataTracker.transport</name>
-  <value>builtin:AppDataTrackerFeed</value>
-</property>
-<property>
-  <name>dt.attr.METRICS_TRANSPORT</name>
-  <value>builtin:AppDataTrackerFeed</value>
-</property>
-```
-
-All the applications launched after the App Data Tracker is enabled will have metrics sent to it.
-
-**Note**: The App Data Tracker will be shown running in dtManage as a “system app”.  It will show up if the “show system apps” button is pressed.
-
-By default, the time buckets App Data Tracker aggregates upon are one minute, one hour and one day.  It can be overridden by changing the operator attribute `METRICS_DIMENSIONS_SCHEME`.
-
-Also by default, the app data tracker performs all these aggregations: SUM, MIN, MAX, AVG, COUNT, FIRST, LAST on all number metrics.  You can also override by changing the same operator attribute `METRICS_DIMENSIONS_SCHEME`, provided the custom aggregator is known to the App Data Tracker.  (See next section)
-
-# Custom Aggregator in App Data Tracker
-Custom aggregators allow you to do your own custom computation on statistics generated by any of your applications. In order to implement a Custom aggregator you have to do two things:
-
-1. Combining new inputs with the current aggregation
-2. Combining two aggregations together into one aggregation
-
-Let’s consider the case where we want to perform the following rolling average:
-
-Y_n = ½ * X_n + ½ * X_n-1 + ¼ * X_n-2 + ⅛ * X_n-3 +...
-
-This aggregation could be performed by the following Custom Aggregator:
-
-```java
-@Name("IIRAVG")
-public class AggregatorIIRAVG extends AbstractIncrementalAggregator
-{
-  ...
-
-  private void aggregateHelper(DimensionsEvent dest, DimensionsEvent src)
-  {
-    double[] destVals = dest.getAggregates().getFieldsDouble();
-    double[] srcVals = src.getAggregates().getFieldsDouble();
-
-    for (int index = 0; index < destLongs.length; index++) {
-      destVals[index] = .5 * destVals[index] + .5 * srcVals[index];
-    }
-  }
-
-  @Override
-  public void aggregate(Aggregate dest, InputEvent src)
-  {
-    //Aggregate a current aggregation with a new input
-    aggregateHelper(dest, src);
-  }
-
-  @Override
-  public void aggregate(Aggregate destAgg, Aggregate srcAgg)
-  {
-    //Combine two existing aggregations together
-    aggregateHelper(destAgg, srcAgg);
-  }
-}
-```
-
-## Discovery of Custom Aggregators
-AppDataTracker searches for custom aggregator jars under the following directories statically before launching:
-
-1. {dt\_installation\_dir}/plugin/aggregators
-2. {user\_home\_dir}/.dt/plugin/aggregators
-
-It uses reflection to find all the classes that extend from `IncrementalAggregator` and `OTFAggregator` in these jars and registers them with the name provided by `@Name` annotation (or class name when `@Name` is absent).
-
-# Using `METRICS_DIMENSIONS_SCHEME`
-
-Here is a sample code snippet on how you can make use of `METRICS_DIMENSIONS_SCHEME` to set your own time buckets and your own set of aggregators for certain `AutoMetric`s performed by the App Data Tracker in your application.
-
-```java
-  @Override
-  public void populateDAG(DAG dag, Configuration configuration)
-  {
-    ...
-    LineReceiver lineReceiver = dag.addOperator("LineReceiver", new LineReceiver());
-    ...
-    AutoMetric.DimensionsScheme dimensionsScheme = new AutoMetric.DimensionsScheme()
-    {
-      String[] timeBuckets = new String[] { "1s", "1m", "1h" };
-      String[] lengthAggregators = new String[] { "IIRAVG", "SUM" };
-      String[] countAggregators = new String[] { "SUM" };
-
-      /* Setting the aggregation time bucket to be one second, one minute and one hour */
-      @Override
-      public String[] getTimeBuckets()
-      {
-        return timeBuckets;
-      }
-
-      @Override
-      public String[] getDimensionAggregationsFor(String logicalMetricName)
-      {
-        if ("length".equals(logicalMetricName)) {
-          return lengthAggregators;
-        } else if ("count".equals(logicalMetricName)) {
-          return countAggregators;
-        } else {
-          return null; // use default
-        }
-      }
-    };
-
-    dag.setAttribute(lineReceiver, OperatorContext.METRICS_DIMENSIONS_SCHEME, dimensionsScheme);
-    ...
-  }
-```
-
-
-# Dashboards
-With App Data Tracker enabled, you can visualize the AutoMetrics and system metrics in the Dashboards within dtManage.   Refer back to the diagram in the App Data Tracker section, dtGateway relays queries and query results to and from the App Data Tracker.  In this way, dtManage sends queries and receives results from the App Data Tracker via dtGateway and uses the results to let the user visualize the data.
-
-Click on the visualize button in dtManage's application page.
-
-![AppDataTracker](images/autometrics/visualize.png)
-
-You will see the dashboard for the AutoMetrics and the system metrics.
-
-![AppDataTracker](images/autometrics/dashboard.png)
-
-The left widget shows the AutoMetrics of `line` and `count` for the LineReceiver operator.  The right widget shows the system metrics.
-
-The Dashboards have some simple builtin widgets to visualize the data.  Line charts and bar charts are some examples.
-Users will be able to implement their own widgets to visualize their data.

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/configuration_packages.md
----------------------------------------------------------------------
diff --git a/configuration_packages.md b/configuration_packages.md
deleted file mode 100644
index 30f1717..0000000
--- a/configuration_packages.md
+++ /dev/null
@@ -1,242 +0,0 @@
-Apache Apex Configuration Packages
-==================================
-
-An Apache Apex Application Configuration Package is a zip file that contains
-configuration files and additional files to be launched with an
-[Application Package](application_packages.md) using 
-DTCLI or REST API.  This guide assumes the reader’s familiarity of
-Application Package.  Please read the Application Package document to
-get yourself familiar with the concept first if you have not done so.
-
-#Requirements 
-
-You will need have the following installed:
-
-1. Apache Maven 3.0 or later (for assembling the Config Package)
-2. Apex 3.0.0 or later (for launching the App Package with the Config
-    Package in your cluster)
-
-#Creating Your First Configuration Package 
-
-You can create a Configuration Package using your Linux command line, or
-using your favorite IDE.  
-
-## Using Command Line
-
-First, change to the directory where you put your projects, and create a
-DT configuration project using Maven by running the following command.
- Replace "com.example", "mydtconfig" and "1.0-SNAPSHOT" with the
-appropriate values:
-
-    $ mvn archetype:generate \
-     -DarchetypeGroupId=org.apache.apex \
-     -DarchetypeArtifactId=apex-conf-archetype -DarchetypeVersion=3.2.0-incubating \
-     -DgroupId=com.example -Dpackage=com.example.mydtconfig -DartifactId=mydtconfig \
-     -Dversion=1.0-SNAPSHOT
-
-This creates a Maven project named "mydtconfig". Open it with your
-favorite IDE (e.g. NetBeans, Eclipse, IntelliJ IDEA).  Try it out by
-running the following command:
-
-```
-$ mvn package                                                         
-```
-
-The "mvn package" command creates the Config Package file in target
-directory as target/mydtconfig.apc. You will be able to use that
-Configuration Package file to launch an Apache Apex application.
-
-## Using IDE 
-
-Alternatively, you can do the above steps all within your IDE.  For
-example, in NetBeans, select File -\> New Project.  Then choose “Maven”
-and “Project from Archetype” in the dialog box, as shown.
-
-![](images/AppConfig/ApplicationConfigurationPackages.html-image01.png)
-
-Then fill the Group ID, Artifact ID, Version and Repository entries as
-shown below.
-
-![](images/AppConfig/ApplicationConfigurationPackages.html-image02.png)
-
-Group ID: org.apache.apex
-Artifact ID: apex-conf-archetype
-Version: 3.2.0-incubating (or any later version)
-
-Press Next and fill out the rest of the required information. For
-example:
-
-![](images/AppConfig/ApplicationConfigurationPackages.html-image00.png)
-
-Click Finish, and now you have created your own Apex
-Configuration Package project.  The procedure for other IDEs, like
-Eclipse or IntelliJ, is similar.
-
-
-# Assembling your own configuration package 
-
-Inside the project created by the archetype, these are the files that
-you should know about when assembling your own configuration package:
-
-    ./pom.xml
-    ./src/main/resources/classpath
-    ./src/main/resources/files
-    ./src/main/resources/META-INF/properties.xml
-    ./src/main/resources/META-INF/properties-{appname}.xml
-
-## pom.xml 
-
-Example:
-
-```
-  <groupId>com.example</groupId>
-  <version>1.0.0</version>
-  <artifactId>mydtconf</artifactId>
-  <packaging>jar</packaging>
-  <!-- change these to the appropriate values -->
-  <name>My DataTorrent Application Configuration</name>
-  <description>My DataTorrent Application Configuration Description</description>
-  <properties>
-    <datatorrent.apppackage.name>mydtapp</datatorrent.apppackage.name>
-    <datatorrent.apppackage.minversion>1.0.0</datatorrent.apppackage.minversion>
-   <datatorrent.apppackage.maxversion>1.9999.9999</datatorrent.apppackage.maxversion>
-    <datatorrent.appconf.classpath>classpath/*</datatorrent.appconf.classpath>
-    <datatorrent.appconf.files>files/*</datatorrent.appconf.files>
-  </properties> 
-
-```
-In pom.xml, you can change the following keys to your desired values
-
-* ```<groupId>```
-* ```<version>```
-* ```<artifactId>```
-* ```<name> ```
-* ```<description>```
-
-You can also change the values of 
-
-* ```<datatorrent.apppackage.name>```
-* ```<datatorrent.apppackage.minversion>```
-* ```<datatorrent.apppackage.maxversion>```
-
-to reflect what app packages should be used with this configuration package.  Apex will use this information to check whether a
-configuration package is compatible with the application package when you issue a launch command.
-
-## ./src/main/resources/classpath 
-
-Place any file in this directory that you’d like to be copied to the
-compute machines when launching an application and included in the
-classpath of the application.  Example of such files are Java properties
-files and jar files.
-
-## ./src/main/resources/files 
-
-Place any file in this directory that you’d like to be copied to the
-compute machines when launching an application but not included in the
-classpath of the application.
-
-## Properties XML file
-
-A properties xml file consists of a set of key-value pairs.  The set of
-key-value pairs specifies the configuration options the application
-should be launched with.  
-
-Example:
-```
-<configuration>
-  <property>
-    <name>some-property-name</name>
-    <value>some-property-value</value>
-  </property>
-   ...
-</configuration>
-```
-Names of properties XML file:
-
-*  **properties.xml:** Properties that are global to the Configuration
-Package
-*  **properties-{appName}.xml:** Properties that are specific when launching
-an application with the specified appName within the Application
-Package.
-
-After you are done with the above, remember to do mvn package to
-generate a new configuration package, which will be located in the
-target directory in your project.
-
-## Zip structure of configuration package 
-Apex Application Configuration Package files are zip files.  You
-can examine the content of any Application Configuration Package by
-using unzip -t on your Linux command line.  The structure of the zip
-file is as follow:
-
-```
-META-INF
-  MANIFEST.MF
-  properties.xml
-  properties-{appname}.xml
-classpath
-  {classpath files}
-files
-  {files} 
-```
-
-
-
-#Launching with CLI 
-
-`-conf` option of the launch command in CLI supports specifying configuration package in the local filesystem.  Example:
-
-    dt\> launch DTApp-mydtapp-1.0.0.jar -conf DTConfig-mydtconfig-1.0.0.jar
-
-This command expects both the application package and the configuration package to be in the local file system.
-
-
-
-# Related REST API 
-
-### POST /ws/v2/configPackages
-
-Payload: Raw content of configuration package zip
-
-Function: Creates or replace a configuration package zip file in HDFS
-
-Curl example:
-
-    $ curl -XPOST -T DTConfig-{name}.jar http://{yourhost:port}/ws/v2/configPackages
-
-### GET /ws/v2/configPackages?appPackageName=...&appPackageVersion=... 
-
-All query parameters are optional
-
-Function: Returns the configuration packages that the user is authorized to use and that are compatible with the specified appPackageName, appPackageVersion and appName. 
-
-### GET /ws/v2/configPackages/``<user>``?appPackageName=...&appPackageVersion=... 
-
-All query parameters are optional
-
-Function: Returns the configuration packages under the specified user and that are compatible with the specified appPackageName, appPackageVersion and appName.
-
-### GET /ws/v2/configPackages/```<user>```/```<name>``` 
-
-Function: Returns the information of the specified configuration package
-
-### GET /ws/v2/configPackages/```<user>```/```<name>```/download 
-
-Function: Returns the raw config package file
-
-Curl example:
-
-```sh
-$ curl http://{yourhost:port}/ws/v2/configPackages/{user}/{name}/download \> DTConfig-xyz.jar
-$ unzip -t DTConfig-xyz.jar
-```
-
-### POST /ws/v2/appPackages/```<user>```/```<app-pkg-name>```/```<app-pkg-version>```/applications/{app-name}/launch?configPackage=```<user>```/```<confpkgname>```
-
-Function: Launches the app package with the specified configuration package stored in HDFS.
-
-Curl example:
-
-```sh
-$ curl -XPOST -d ’{}’ http://{yourhost:port}/ws/v2/appPackages/{user}/{app-pkg-name}/{app-pkg-version}/applications/{app-name}/launch?configPackage={user}/{confpkgname}
-```
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/docs/apex.md
----------------------------------------------------------------------
diff --git a/docs/apex.md b/docs/apex.md
new file mode 100644
index 0000000..215a957
--- /dev/null
+++ b/docs/apex.md
@@ -0,0 +1,14 @@
+Apache Apex
+================================================================================
+
+Apache Apex (incubating) is the industry’s only open source, enterprise-grade unified stream and batch processing engine.  Apache Apex includes key features requested by open source developer community that are not available in current open source technologies.
+
+* Event processing guarantees
+* In-memory performance & scalability
+* Fault tolerance and state management
+* Native rolling and tumbling window support
+* Hadoop-native YARN & HDFS implementation
+
+For additional information visit [Apache Apex](http://apex.incubator.apache.org/).
+
+[![](images/apex_logo.png)](http://apex.incubator.apache.org/)

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/docs/apex_development_setup.md
----------------------------------------------------------------------
diff --git a/docs/apex_development_setup.md b/docs/apex_development_setup.md
new file mode 100644
index 0000000..777f2f9
--- /dev/null
+++ b/docs/apex_development_setup.md
@@ -0,0 +1,151 @@
+Apache Apex Development Environment Setup
+=========================================
+
+This document discusses the steps needed for setting up a development environment for creating applications that run on the Apache Apex or the DataTorrent RTS streaming platform.
+
+
+Microsoft Windows
+------------------------------
+
+There are a few tools that will be helpful when developing Apache Apex applications, some required and some optional:
+
+1.  *git* -- A revision control system (version 1.7.1 or later). There are multiple git clients available for Windows (<http://git-scm.com/download/win> for example), so download and install a client of your choice.
+
+2.  *java JDK* (not JRE). Includes the Java Runtime Environment as well as the Java compiler and a variety of tools (version 1.7.0\_79 or later). Can be downloaded from the Oracle website.
+
+3.  *maven* -- Apache Maven is a build system for Java projects (version 3.0.5 or later). It can be downloaded from <https://maven.apache.org/download.cgi>.
+
+4.  *VirtualBox* -- Oracle VirtualBox is a virtual machine manager (version 4.3 or later) and can be downloaded from <https://www.virtualbox.org/wiki/Downloads>. It is needed to run the Data Torrent Sandbox.
+
+5.  *DataTorrent Sandbox* -- The sandbox can be downloaded from <https://www.datatorrent.com/download>. It is useful for testing simple applications since it contains Apache Hadoop and Data Torrent RTS 3.1.1 pre-installed with a time-limited Enterprise License. If you already installed the RTS Enterprise Edition (evaluation or production license) on a cluster, you can use that setup for deployment and testing instead of the sandbox.
+
+6.  (Optional) If you prefer to use an IDE (Integrated Development Environment) such as *NetBeans*, *Eclipse* or *IntelliJ*, install that as well.
+
+
+After installing these tools, make sure that the directories containing the executable files are in your PATH environment; for example, for the JDK executables like _java_ and _javac_, the directory might be something like `C:\\Program Files\\Java\\jdk1.7.0\_80\\bin`; for _git_ it might be `C:\\Program Files\\Git\\bin`; and for maven it might be `C:\\Users\\user\\Software\\apache-maven-3.3.3\\bin`. Open a console window and enter the command:
+
+    echo %PATH%
+
+to see the value of the `PATH` variable and verify that the above directories are present. If not, you can change its value clicking on the button at _Control Panel_ &#x21e8; _Advanced System Settings_ &#x21e8; _Advanced tab_ &#x21e8; _Environment Variables_.
+
+
+Now run the following commands and ensure that the output is something similar to that shown in the table below:
+
+
+<table>
+<colgroup>
+<col width="30%" />
+<col width="70%" />
+</colgroup>
+<tbody>
+<tr class="odd">
+<td align="left"><p>Command</p></td>
+<td align="left"><p>Output</p></td>
+</tr>
+<tr class="even">
+<td align="left"><p><tt>javac -version</tt></p></td>
+<td align="left"><p>javac 1.7.0_80</p></td>
+</tr>
+<tr class="odd">
+<td align="left"><p><tt>java -version</tt></p></td>
+<td align="left"><p>java version &quot;1.7.0_80&quot;</p>
+<p>Java(TM) SE Runtime Environment (build 1.7.0_80-b15)</p>
+<p>Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)</p></td>
+</tr>
+<tr class="even">
+<td align="left"><p><tt>git --version</tt></p></td>
+<td align="left"><p>git version 2.6.1.windows.1</p></td>
+</tr>
+<tr class="odd">
+<td align="left"><p><tt>mvn --version</tt></p></td>
+<td align="left"><p>Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T06:57:37-05:00)</p>
+<p>Maven home: C:\Users\ram\Software\apache-maven-3.3.3\bin\..</p>
+<p>Java version: 1.7.0_80, vendor: Oracle Corporation</p>
+<p>Java home: C:\Program Files\Java\jdk1.7.0_80\jre</p>
+<p>Default locale: en_US, platform encoding: Cp1252</p>
+<p>OS name: &quot;windows 8&quot;, version: &quot;6.2&quot;, arch: &quot;amd64&quot;, family: &quot;windows&quot;</p></td>
+</tr>
+</tbody>
+</table>
+
+
+To install the sandbox, first download it from <https://www.datatorrent.com/download> and import the downloaded file into VirtualBox. Once the import completes, you can select it and click the  Start button to start the sandbox.
+
+
+The sandbox is configured with 6GB RAM; if your development machine has 16GB or more, you can increase the sandbox RAM to 8GB or more using the VirtualBox console. This will yield better performance and support larger applications. Additionally, you can change the network adapter from **NAT** to **Bridged Adapter**; this will allow you to login to the sandbox from your host machine using an _ssh_ tool like **PuTTY** and also to transfer files to and from the host using `pscp` on Windows. Of course all such configuration must be done when when the sandbox is not running.
+
+
+You can choose to develop either directly on the sandbox or on your development machine. The advantage of the former is that most of the tools (e.g. _jdk_, _git_, _maven_) are pre-installed and also the package files created by your project are directly available to the Data Torrent tools such as  **dtManage** and **dtcli**. The disadvantage is that the sandbox is a memory-limited environment so running a memory-hungry tool like a Java IDE on it may starve other applications of memory.
+
+
+You can now use the maven archetype to create a basic Apache Apex project as follows: Put these lines in a Windows command file called, for example, `newapp.cmd` and run it:
+
+    @echo off
+    @rem Script for creating a new application
+    setlocal
+    mvn archetype:generate ^
+    -DarchetypeRepository=https://www.datatorrent.com/maven/content/repositories/releases ^
+      -DarchetypeGroupId=com.datatorrent ^
+      -DarchetypeArtifactId=apex-app-archetype ^
+      -DarchetypeVersion=3.1.1 ^
+      -DgroupId=com.example ^
+      -Dpackage=com.example.myapexapp ^
+      -DartifactId=myapexapp ^
+      -Dversion=1.0-SNAPSHOT
+    endlocal
+
+
+
+The caret (^) at the end of some lines indicates that a continuation line follows. When you run this file, the properties will be displayed and you will be prompted with `` Y: :``; just press **Enter** to complete the project generation.
+
+
+This command file also exists in the Data Torrent _examples_ repository which you can check out with:
+
+    git clone https://github.com/DataTorrent/examples
+
+You will find the script under `examples\tutorials\topnwords\scripts\newapp.cmd`.
+
+You can also, if you prefer, use an IDE to generate the project as described in Section 3 of [Application Packages](application_packages.md) but use the archetype version 3.1.1 instead of 3.0.0.
+
+
+When the run completes successfully, you should see a new directory named `myapexapp` containing a maven project for building a basic Apache Apex application. It includes 3 source files:**Application.java**,  **RandomNumberGenerator.java** and **ApplicationTest.java**. You can now build the application by stepping into the new directory and running the appropriate maven command:
+
+    cd myapexapp
+    mvn clean package -DskipTests
+
+The build should create the application package file `myapexapp\target\myapexapp-1.0-SNAPSHOT.apa`. This file can then be uploaded to the Data Torrent GUI tool on the sandbox (called **dtManage**) and launched  from there. It generates a stream of random numbers and prints them out, each prefixed by the string  `hello world: `.  If you built this package on the host, you can transfer it to the sandbox using the `pscp` tool bundled with **PuTTY** mentioned earlier.
+
+
+If you want to checkout the Apache Apex source repositories and build them, you can do so by running the script `build-apex.cmd` located in the same place in the examples repository described above. The source repositories contain more substantial demo applications and the associated source code. Alternatively, if you do not want to use the script, you can follow these simple manual steps:
+
+
+1.  Check out the source code repositories:
+
+        git clone https://github.com/apache/incubator-apex-core
+        git clone https://github.com/apache/incubator-apex-malhar
+
+2.  Switch to the appropriate release branch and build each repository:
+
+        pushd incubator-apex-core
+        git checkout release-3.1
+        mvn clean install -DskipTests
+        popd
+        pushd incubator-apex-malhar
+        git checkout release-3.1
+        mvn clean install -DskipTests
+        popd
+
+The `install` argument to the `mvn` command installs resources from each project to your local maven repository (typically `.m2/repository` under your home directory), and **not** to the system directories, so Administrator privileges are not required. The  `-DskipTests` argument skips running unit tests since they take a long time. If this is a first-time installation, it might take several minutes to complete because maven will download a number of associated plugins.
+
+After the build completes, you should see the demo application package files in the target directory under each demo subdirectory in `incubator-apex-malhar\demos\`.
+
+Linux
+------------------
+
+Most of the instructions for Linux (and other Unix-like systems) are similar to those for Windows described above, so we will just note the differences.
+
+
+The pre-requisites (such as _git_, _maven_, etc.) are the same as for Windows described above; please run the commands in the table and ensure that appropriate versions are present in your PATH environment variable (the command to display that variable is: `echo $PATH`).
+
+
+The maven archetype command is the same except that continuation lines use a backslash (``\``) instead of caret (``^``); the script for it is available in the same location and is named `newapp` (without the `.cmd` extension). The script to checkout and build the Apache Apex repositories is named `build-apex`.

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/docs/apex_malhar.md
----------------------------------------------------------------------
diff --git a/docs/apex_malhar.md b/docs/apex_malhar.md
new file mode 100644
index 0000000..ef2e371
--- /dev/null
+++ b/docs/apex_malhar.md
@@ -0,0 +1,65 @@
+Apache Apex Malhar
+================================================================================
+
+Apache Apex Malhar is an open source operator and codec library that can be used with the Apache Apex platform to build real-time streaming applications.  As part of enabling enterprises extract value quickly, Malhar operators help get data in, analyze it in real-time and get data out of Hadoop in real-time with no paradigm limitations.  In addition to the operators, the library contains a number of demos applications, demonstrating operator features and capabilities.
+
+![MalharDiagram](images/MalharOperatorOverview.png)
+
+# Capabilities common across Malhar operators
+
+For most streaming platforms, connectors are afterthoughts and often end up being simple ‘bolt-ons’ to the platform. As a result they often cause performance issues or data loss when put through failure scenarios and scalability requirements. Malhar operators do not face these issues as they were designed to be integral parts of apex*.md RTS. Hence, they have following core streaming runtime capabilities
+
+1.  **Fault tolerance** – Apache Apex Malhar operators where applicable have fault tolerance built in. They use the checkpoint capability provided by the framework to ensure that there is no data loss under ANY failure scenario.
+2.  **Processing guarantees** – Malhar operators where applicable provide out of the box support for ALL three processing guarantees – exactly once, at-least once & at-most once WITHOUT requiring the user to write any additional code.  Some operators like MQTT operator deal with source systems that cant track processed data and hence need the operators to keep track of the data. Malhar has support for a generic operator that uses alternate storage like HDFS to facilitate this. Finally for databases that support transactions or support any sort of atomic batch operations Malhar operators can do exactly once down to the tuple level.
+3.  **Dynamic updates** – Based on changing business conditions you often have to tweak several parameters used by the operators in your streaming application without incurring any application downtime. You can also change properties of a Malhar operator at runtime without having to bring down the application.
+4.  **Ease of extensibility** – Malhar operators are based on templates that are easy to extend.
+5.  **Partitioning support** – In streaming applications the input data stream often needs to be partitioned based on the contents of the stream. Also for operators that ingest data from external systems partitioning needs to be done based on the capabilities of the external system. E.g. With the Kafka or Flume operator, the operator can automatically scale up or down based on the changes in the number of Kafka partitions or Flume channels
+
+# Operator Library Overview
+
+## Input/output connectors
+
+Below is a summary of the various sub categories of input and output operators. Input operators also have a corresponding output operator
+
+*   **File Systems** – Most streaming analytics use cases we have seen require the data to be stored in HDFS or perhaps S3 if the application is running in AWS. Also, customers often need to re-run their streaming analytical applications against historical data or consume data from upstream processes that are perhaps writing to some NFS share. Hence, it’s not just enough to be able to save data to various file systems. You also have to be able to read data from them. RTS supports input & output operators for HDFS, S3, NFS & Local Files
+*   **Flume** – NOTE: Flume operator is not yet part of Malhar
+
+Many customers have existing Flume deployments that are being used to aggregate log data from variety of sources. However Flume does not allow analytics on the log data on the fly. The Flume input/output operator enables RTS to consume data from flume and analyze it in real-time before being persisted.
+
+*   **Relational databases** – Most stream processing use cases require some reference data lookups to enrich, tag or filter streaming data. There is also a need to save results of the streaming analytical computation to a database so an operational dashboard can see them. RTS supports a JDBC operator so you can read/write data from any JDBC compliant RDBMS like Oracle, MySQL etc.
+*   **NoSQL databases** –NoSQL key-value pair databases like Cassandra & HBase are becoming a common part of streaming analytics application architectures to lookup reference data or store results. Malhar has operators for HBase, Cassandra, Accumulo (common with govt. & healthcare companies) MongoDB & CouchDB.
+*   **Messaging systems** – JMS brokers have been the workhorses of messaging infrastructure in most enterprises. Also Kafka is fast coming up in almost every customer we talk to. Malhar has operators to read/write to Kafka, any JMS implementation, ZeroMQ & RabbitMQ.
+*   **Notification systems** – Almost every streaming analytics application has some notification requirements that are tied to a business condition being triggered. Malhar supports sending notifications via SMTP & SNMP. It also has an alert escalation mechanism built in so users don’t get spammed by notifications (a common drawback in most streaming platforms)
+*   **In-memory Databases & Caching platforms** - Some streaming use cases need instantaneous access to shared state across the application. Caching platforms and in-memory databases serve this purpose really well. To support these use cases, Malhar has operators for memcached & Redis
+*   **Protocols** - Streaming use cases driven by machine-to-machine communication have one thing in common – there is no standard dominant protocol being used for communication. Malhar currently has support for MQTT. It is one of the more commonly, adopted protocols we see in the IoT space. Malhar also provides connectors that can directly talk to HTTP, RSS, Socket, WebSocket & FTP sources
+
+
+
+## Compute
+
+One of the most important promises of a streaming analytics platform like Apache Apex is the ability to do analytics in real-time. However delivering on the promise becomes really difficult when the platform does not provide out of the box operators to support variety of common compute functions as the user then has to worry about making these scalable, fault tolerant etc. Malhar takes this responsibility away from the application developer by providing a huge variety of out of the box computational operators. The application developer can thus focus on the analysis.
+
+Below is just a snapshot of the compute operators available in Malhar
+
+*   Statistics & Math - Provide various mathematical and statistical computations over application defined time windows.
+*   Filtering & pattern matching
+*   Machine learning & Algorithms
+*   Real-time model scoring is a very common use case for stream processing platforms. &nbsp;Malhar allows users to invoke their R models from streaming applications
+*   Sorting, Maps, Frequency, TopN, BottomN, Random Generator etc.
+
+
+## Query & Script invocation
+
+Many streaming use cases are legacy implementations that need to be ported over. This often requires re-use some of the existing investments and code that perhaps would be really hard to re-write. With this in mind, Malhar supports invoking external scripts and queries as part of the streaming application using operators for invoking SQL query, Shell script, Ruby, Jython, and JavaScript etc.
+
+## Parsers
+
+There are many industry vertical specific data formats that a streaming application developer might need to parse. Often there are existing parsers available for these that can be directly plugged into an Apache Apex application. For example in the Telco space, a Java based CDR parser can be directly plugged into Apache Apex operator. To further simplify development experience, Malhar also provides some operators for parsing common formats like XML (DOM & SAX), JSON (flat map converter), Apache log files, syslog, etc.
+
+## Stream manipulation
+
+Streaming data aka ‘stream’ is raw data that inevitably needs processing to clean, filter, tag, summarize etc. The goal of Malhar is to enable the application developer to focus on ‘WHAT’ needs to be done to the stream to get it in the right format and not worry about the ‘HOW’. Hence, Malhar has several operators to perform the common stream manipulation actions like – DeDupe, GroupBy, Join, Distinct/Unique, Limit, OrderBy, Split, Sample, Inner join, Outer join, Select, Update etc.
+
+## Social Media
+
+Malhar includes an operator to connect to the popular Twitter stream fire hose.


[10/11] incubator-apex-core git commit: APEXCORE-293 Exclude .yml from rat check.

Posted by th...@apache.org.
APEXCORE-293 Exclude .yml from rat check.


Project: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/commit/269fbb28
Tree: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/tree/269fbb28
Diff: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/diff/269fbb28

Branch: refs/heads/APEXCORE-293
Commit: 269fbb282ff9cd9fef0c8dfd6336ccd67ebb8209
Parents: d26c28a
Author: Thomas Weise <th...@datatorrent.com>
Authored: Wed Mar 2 14:40:52 2016 -0800
Committer: Thomas Weise <th...@datatorrent.com>
Committed: Wed Mar 2 14:40:52 2016 -0800

----------------------------------------------------------------------
 pom.xml | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/269fbb28/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 8dde7db..8f01431 100644
--- a/pom.xml
+++ b/pom.xml
@@ -115,6 +115,7 @@
             <exclude>**/NOTICE.vm</exclude>
             <exclude>**/*.md</exclude>
             <exclude>**/*.txt</exclude>
+            <exclude>**/*.yml</exclude>
             <exclude>**/*.importorder</exclude>
             <exclude>**/archetype-resources/**</exclude>
             <exclude>misc/ide-templates/**</exclude>
@@ -195,6 +196,7 @@
             <exclude>**/archetype-resources/**</exclude>
             <exclude>**/*.md</exclude>
             <exclude>**/*.txt</exclude>
+            <exclude>**/*.yml</exclude>
             <exclude>**/*.importorder</exclude>
             <exclude>misc/ide-templates/**</exclude>
             <exclude>**/NOTICE.vm</exclude>


[08/11] incubator-apex-core git commit: Updated app package doc screenshots, removed references to DTGateway

Posted by th...@apache.org.
Updated app package doc screenshots, removed references to DTGateway


Project: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/commit/6af91261
Tree: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/tree/6af91261
Diff: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/diff/6af91261

Branch: refs/heads/APEXCORE-293
Commit: 6af91261ab261679096e3e789daccd1594bae64e
Parents: cfdacdf
Author: David Yan <da...@datatorrent.com>
Authored: Mon Feb 29 14:34:14 2016 -0800
Committer: Thomas Weise <th...@datatorrent.com>
Committed: Tue Mar 1 17:39:13 2016 -0800

----------------------------------------------------------------------
 docs/application_packages.md                    | 163 +++----------------
 .../ApplicationPackages.html-image00.png        | Bin 0 -> 76495 bytes
 .../ApplicationPackages.html-image01.png        | Bin 0 -> 13996 bytes
 .../ApplicationPackages.html-image02.png        | Bin 0 -> 18882 bytes
 .../ApplicationPackages.html-image03.png        | Bin 0 -> 33572 bytes
 .../ApplicationPackages.html-image04.png        | Bin 0 -> 29660 bytes
 6 files changed, 23 insertions(+), 140 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/6af91261/docs/application_packages.md
----------------------------------------------------------------------
diff --git a/docs/application_packages.md b/docs/application_packages.md
index 06c2980..3a83d46 100644
--- a/docs/application_packages.md
+++ b/docs/application_packages.md
@@ -10,7 +10,7 @@ standard way for assembling and sharing an Apache Apex application.
 You will need have the following installed:
 
 1. Apache Maven 3.0 or later (for assembling the App Package)
-2. Apache Apex 3.0.0 or later (for launching the App Package in your cluster)
+2. Apache Apex 3.2.0 or later (for launching the App Package in your cluster)
 
 # Creating Your First Apex App Package
 
@@ -80,29 +80,38 @@ Apex installation.
 
 ## Using IDE
 
-Alternatively, you can do the above steps all within your IDE.  For
-example, in NetBeans, select File -\> New Project.  Then choose “Maven”
-and “Project from Archetype” in the dialog box, as shown.
+Alternatively, you can do the above steps all within your IDE.  For example, in IDEA IntelliJ, first make sure you have the "Maven Integration" plugin enabled (Use File -\> Settings \-> Plugins).  Then select File -\> New -\> Project.  Choose “Maven”, and check “Create from archetype” in the dialog box, as shown.
 
 ![](images/AppPackage/ApplicationPackages.html-image00.png)
 
-Then fill the Group ID, Artifact ID, Version and Repository entries as shown below.
+Then go ahead and click on the "Add Archetype..." button.
 
-![](images/AppPackage/ApplicationPackages.html-image02.png)
+Then fill out the Group ID, Artifact ID, and Version entries, and leave the Repository entry blank, as shown below.
+
+![](images/AppPackage/ApplicationPackages.html-image01.png)
 
 Group ID: org.apache.apex
 Artifact ID: apex-app-archetype
 Version: 3.2.0-incubating (or any later version)
 
-Press Next and fill out the rest of the required information. For
-example:
+Click OK. The archetype will appear in the list, selected.  Note that this "Add Archetype..." step is only required the first time you use the archetype.  You can select the archetype directly after it has been added the first time.
 
-![](images/AppPackage/ApplicationPackages.html-image01.png)
+Click Next, and fill out the rest of the required information. For example:
+
+![](images/AppPackage/ApplicationPackages.html-image02.png)
+
+Click Next, and verify the information shown on the next screen:
+
+![](images/AppPackage/ApplicationPackages.html-image03.png)
+
+Click Next, and fill out the project name and location: 
+
+![](images/AppPackage/ApplicationPackages.html-image04.png)
 
 Click Finish, and now you have created your own Apache Apex App Package
 project, with a default unit test.  You can run the unit test, make code
 changes or make dependency changes within your IDE.  The procedure for
-other IDEs, like Eclipse or IntelliJ, is similar.
+other IDEs, like Eclipse or NetBeans, is similar.
 
 # Writing Your Own App Package
 
@@ -434,12 +443,11 @@ app package default configuration as META-INF/properties.xml, from app
 package configuration in the conf directory, from launch time defines,
 etc), the precedence of sources, from highest to lowest, is as follows:
 
-1. Launch time defines (using -D option in CLI, or the POST payload
-    with the Gateway REST API’s launch call)
+1. Launch time defines (using -D option in CLI)
 2. Launch time specified configuration file in file system (using -conf
     option in CLI)
 3. Launch time specified package configuration (using -apconf option in
-    CLI or the conf={confname} with Gateway REST API’s launch call)
+    CLI)
 4. Configuration from \$HOME/.dt/dt-site.xml
 5. Application defaults within the package as
     META-INF/properties-{appname}.xml
@@ -497,137 +505,12 @@ There are four top level directories in an Application Package:
 2. "lib" contains all dependency jars
 3. "conf" contains all the pre-set configuration XML files.
 4. "META-INF" contains the MANIFEST.MF file and the properties.xml file.
-5. “resources” contains other files that are to be served by the Gateway on behalf of the app package.
-
-
-# Managing Application Packages Through DT Gateway
-
-The DT Gateway provides storing and retrieving Application Packages to
-and from your distributed file system, e.g. HDFS.
-
-## Storing an Application Package
-
-You can store your Application Packages through DT Gateway using this
-REST call:
-
-```
- POST /ws/v2/appPackages
-```
-
-The payload is the raw content of your Application Package.  For
-example, you can issue this request using curl on your Linux command
-line like this, assuming your DT Gateway is accepting requests at
-localhost:9090:
-
-```
-$ curl -XPOST -T <app-package-file> http://localhost:9090/ws/v2/appPackages
-```
-
-## Getting Meta Information on Application Packages
-
-
-You can get the meta information on Application Packages stored through
-DT Gateway using this call.  The information includes the logical plan
-of each application within the Application Package.
-
-```
- GET /ws/v2/appPackages/{owner}/{pkgName}/{pkgVersion}
-```
-
-## Getting Available Operators In Application Package
-
-You can get the list of available operators in the Application Package
-using this call.
-
-```
-GET /ws/v2/appPackages/{owner}/{pkgName}/{pkgVersion}/operators?parent={parent}
-```
-
-The parent parameter is optional.  If given, parent should be the fully
-qualified class name.  It will only return operators that derive from
-that class or interface. For example, if parent is
-com.datatorrent.api.InputOperator, this call will only return input
-operators provided by the Application Package.
-
-## Getting Properties of Operators in Application Package
-
-You can get the list of properties of any operator in the Application
-Package using this call.
-
-```
-GET  /ws/v2/appPackages/{owner}/{pkgName}/{pkgVersion}/operators/{className}
-```
-
-## Getting List of Pre-Set Configurations in Application Package
-
-You can get a list of pre-set configurations within the Application
-Package using this call.
-
-```
-GET /ws/v2/appPackages/{owner}/{pkgName}/{packageVersion}/configs
-```
-
-You can also get the content of a specific pre-set configuration within
-the Application Package.
-
-```
- GET /ws/v2/appPackages/{owner}/{pkgName}/{pkgVersion}/configs/{configName}
-```
-
-## Changing Pre-Set Configurations in Application Package
-
-You can create or replace pre-set configurations within the Application
-Package
-```
- PUT   /ws/v2/appPackages/{owner}/{pkgName}/{pkgVersion}/configs/{configName}
-```
-The payload of this PUT call is the XML file that represents the pre-set configuration.  The Content-Type of the payload is "application/xml" and you can delete a pre-set configuration within the Application Package.
-```
- DELETE /ws/v2/appPackages/{owner}/{pkgName}/{pkgVersion}/configs/{configName}
-```
-
-## Retrieving an Application Package
-
-You can download the Application Package file.  This Application Package
-is not necessarily the same file as the one that was originally uploaded
-since the pre-set configurations may have been modified.
-
-```
- GET /ws/v2/appPackages/{owner}/{pkgName}/{pkgVersion}/download
-```
-
-## Launching an Application Package
-
-You can launch an application within an Application Package.
-```
-POST /ws/v2/appPackages/{owner}/{pkgName}/{pkgVersion}/applications/{appName}/launch?config={configName}
-```
-
-The config parameter is optional.  If given, it must be one of the
-pre-set configuration within the given Application Package.  The
-Content-Type of the payload of the POST request is "application/json"
-and should contain the properties to be launched with the application.
- It is of the form:
-
-```
- {"property-name":"property-value", ... }
-```
-
-Here is an example of launching an application through curl:
-
-```
- $ curl -XPOST -d'{"dt.operator.console.prop.stringFormat":"xyz %s"}'
- http://localhost:9090/ws/v2/appPackages/dtadmin/mydtapp/1.0-SNAPSHOT/app
- lications/MyFirstApplication/launch
-```
+5. “resources” contains any other files
 
-Please refer to the [Gateway API](http://docs.datatorrent.com/dtgateway_api/) for the complete specification of the REST API.
 
 # Examining and Launching Application Packages Through Apex CLI
 
-If you are working with Application Packages in the local filesystem and
-do not want to deal with dtGateway, you can use the Apex Command Line Interface (dtcli).  Please refer to the [Gateway API](http://docs.datatorrent.com/dtgateway_api/)
-to see samples for these commands.
+If you are working with Application Packages in the local filesystem, you can use the Apex Command Line Interface (dtcli).  
 
 ## Getting Application Package Meta Information
 

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/6af91261/docs/images/AppPackage/ApplicationPackages.html-image00.png
----------------------------------------------------------------------
diff --git a/docs/images/AppPackage/ApplicationPackages.html-image00.png b/docs/images/AppPackage/ApplicationPackages.html-image00.png
new file mode 100644
index 0000000..af7c53e
Binary files /dev/null and b/docs/images/AppPackage/ApplicationPackages.html-image00.png differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/6af91261/docs/images/AppPackage/ApplicationPackages.html-image01.png
----------------------------------------------------------------------
diff --git a/docs/images/AppPackage/ApplicationPackages.html-image01.png b/docs/images/AppPackage/ApplicationPackages.html-image01.png
new file mode 100644
index 0000000..c11a707
Binary files /dev/null and b/docs/images/AppPackage/ApplicationPackages.html-image01.png differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/6af91261/docs/images/AppPackage/ApplicationPackages.html-image02.png
----------------------------------------------------------------------
diff --git a/docs/images/AppPackage/ApplicationPackages.html-image02.png b/docs/images/AppPackage/ApplicationPackages.html-image02.png
new file mode 100644
index 0000000..c7deddf
Binary files /dev/null and b/docs/images/AppPackage/ApplicationPackages.html-image02.png differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/6af91261/docs/images/AppPackage/ApplicationPackages.html-image03.png
----------------------------------------------------------------------
diff --git a/docs/images/AppPackage/ApplicationPackages.html-image03.png b/docs/images/AppPackage/ApplicationPackages.html-image03.png
new file mode 100644
index 0000000..bc9e388
Binary files /dev/null and b/docs/images/AppPackage/ApplicationPackages.html-image03.png differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/6af91261/docs/images/AppPackage/ApplicationPackages.html-image04.png
----------------------------------------------------------------------
diff --git a/docs/images/AppPackage/ApplicationPackages.html-image04.png b/docs/images/AppPackage/ApplicationPackages.html-image04.png
new file mode 100644
index 0000000..a39e8e0
Binary files /dev/null and b/docs/images/AppPackage/ApplicationPackages.html-image04.png differ


[06/11] incubator-apex-core git commit: Migrating docs

Posted by th...@apache.org.
Migrating docs


Project: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/commit/7af835b0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/tree/7af835b0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/diff/7af835b0

Branch: refs/heads/APEXCORE-293
Commit: 7af835b012475a61d08e067cb35cec9b1429f225
Parents: a10513d
Author: sashadt <sa...@datatorrent.com>
Authored: Fri Jan 29 18:39:20 2016 -0800
Committer: Thomas Weise <th...@datatorrent.com>
Committed: Sun Feb 28 22:46:41 2016 -0800

----------------------------------------------------------------------
 apex.md                                         |   14 -
 apex_development_setup.md                       |  151 -
 application_development.md                      | 2934 ------------------
 application_packages.md                         |  669 ----
 autometrics.md                                  |  311 --
 configuration_packages.md                       |  242 --
 docs/apex.md                                    |   14 +
 docs/apex_development_setup.md                  |  151 +
 docs/apex_malhar.md                             |   65 +
 docs/application_development.md                 | 2934 ++++++++++++++++++
 docs/application_packages.md                    |  669 ++++
 docs/autometrics.md                             |  311 ++
 docs/dtcli.md                                   |  273 ++
 docs/images/MalharOperatorOverview.png          |  Bin 0 -> 297948 bytes
 docs/images/apex_logo.png                       |  Bin 0 -> 35621 bytes
 .../ApplicationDeveloperGuide.html-image00.png  |  Bin 0 -> 30204 bytes
 .../ApplicationDeveloperGuide.html-image01.png  |  Bin 0 -> 44041 bytes
 .../ApplicationDeveloperGuide.html-image02.png  |  Bin 0 -> 21927 bytes
 .../ApplicationDeveloperGuide.html-image03.png  |  Bin 0 -> 66578 bytes
 .../ApplicationDeveloperGuide.html-image04.png  |  Bin 0 -> 47909 bytes
 .../ApplicationDeveloperGuide.html-image05.png  |  Bin 0 -> 40228 bytes
 .../ApplicationDeveloperGuide.html-image06.png  |  Bin 0 -> 37807 bytes
 .../ApplicationDeveloperGuide.html-image07.png  |  Bin 0 -> 38504 bytes
 .../ApplicationDeveloperGuide.html-image08.png  |  Bin 0 -> 29070 bytes
 .../ApplicationDeveloperGuide.html-image09.png  |  Bin 0 -> 47030 bytes
 docs/images/operator/image00.png                |  Bin 0 -> 19541 bytes
 docs/images/operator/image01.png                |  Bin 0 -> 25962 bytes
 docs/images/operator/image02.png                |  Bin 0 -> 26407 bytes
 docs/images/operator/image03.png                |  Bin 0 -> 9465 bytes
 docs/images/operator/image04.png                |  Bin 0 -> 14620 bytes
 docs/images/operator/image05.png                |  Bin 0 -> 6227 bytes
 docs/operator_development.md                    |  449 +++
 dtcli.md                                        |  273 --
 ...cationConfigurationPackages.html-image00.png |  Bin 50038 -> 0 bytes
 ...cationConfigurationPackages.html-image01.png |  Bin 43756 -> 0 bytes
 ...cationConfigurationPackages.html-image02.png |  Bin 49752 -> 0 bytes
 .../ApplicationPackages.html-image00.png        |  Bin 43756 -> 0 bytes
 .../ApplicationPackages.html-image01.png        |  Bin 29535 -> 0 bytes
 .../ApplicationPackages.html-image02.png        |  Bin 49468 -> 0 bytes
 images/MalharOperatorOverview.png               |  Bin 297948 -> 0 bytes
 images/apex_logo.png                            |  Bin 35621 -> 0 bytes
 .../ApplicationDeveloperGuide.html-image00.png  |  Bin 30204 -> 0 bytes
 .../ApplicationDeveloperGuide.html-image01.png  |  Bin 44041 -> 0 bytes
 .../ApplicationDeveloperGuide.html-image02.png  |  Bin 21927 -> 0 bytes
 .../ApplicationDeveloperGuide.html-image03.png  |  Bin 66578 -> 0 bytes
 .../ApplicationDeveloperGuide.html-image04.png  |  Bin 47909 -> 0 bytes
 .../ApplicationDeveloperGuide.html-image05.png  |  Bin 40228 -> 0 bytes
 .../ApplicationDeveloperGuide.html-image06.png  |  Bin 37807 -> 0 bytes
 .../ApplicationDeveloperGuide.html-image07.png  |  Bin 38504 -> 0 bytes
 .../ApplicationDeveloperGuide.html-image08.png  |  Bin 29070 -> 0 bytes
 .../ApplicationDeveloperGuide.html-image09.png  |  Bin 47030 -> 0 bytes
 images/autometrics/adt.png                      |  Bin 25372 -> 0 bytes
 images/autometrics/dashboard.png                |  Bin 79952 -> 0 bytes
 images/autometrics/visualize.png                |  Bin 35073 -> 0 bytes
 images/operator/image00.png                     |  Bin 19541 -> 0 bytes
 images/operator/image01.png                     |  Bin 25962 -> 0 bytes
 images/operator/image02.png                     |  Bin 26407 -> 0 bytes
 images/operator/image03.png                     |  Bin 9465 -> 0 bytes
 images/operator/image04.png                     |  Bin 14620 -> 0 bytes
 images/operator/image05.png                     |  Bin 6227 -> 0 bytes
 operator_development.md                         |  449 ---
 61 files changed, 4866 insertions(+), 5043 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/apex.md
----------------------------------------------------------------------
diff --git a/apex.md b/apex.md
deleted file mode 100644
index 215a957..0000000
--- a/apex.md
+++ /dev/null
@@ -1,14 +0,0 @@
-Apache Apex
-================================================================================
-
-Apache Apex (incubating) is the industry’s only open source, enterprise-grade unified stream and batch processing engine.  Apache Apex includes key features requested by open source developer community that are not available in current open source technologies.
-
-* Event processing guarantees
-* In-memory performance & scalability
-* Fault tolerance and state management
-* Native rolling and tumbling window support
-* Hadoop-native YARN & HDFS implementation
-
-For additional information visit [Apache Apex](http://apex.incubator.apache.org/).
-
-[![](images/apex_logo.png)](http://apex.incubator.apache.org/)

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/apex_development_setup.md
----------------------------------------------------------------------
diff --git a/apex_development_setup.md b/apex_development_setup.md
deleted file mode 100644
index 777f2f9..0000000
--- a/apex_development_setup.md
+++ /dev/null
@@ -1,151 +0,0 @@
-Apache Apex Development Environment Setup
-=========================================
-
-This document discusses the steps needed for setting up a development environment for creating applications that run on the Apache Apex or the DataTorrent RTS streaming platform.
-
-
-Microsoft Windows
-------------------------------
-
-There are a few tools that will be helpful when developing Apache Apex applications, some required and some optional:
-
-1.  *git* -- A revision control system (version 1.7.1 or later). There are multiple git clients available for Windows (<http://git-scm.com/download/win> for example), so download and install a client of your choice.
-
-2.  *java JDK* (not JRE). Includes the Java Runtime Environment as well as the Java compiler and a variety of tools (version 1.7.0\_79 or later). Can be downloaded from the Oracle website.
-
-3.  *maven* -- Apache Maven is a build system for Java projects (version 3.0.5 or later). It can be downloaded from <https://maven.apache.org/download.cgi>.
-
-4.  *VirtualBox* -- Oracle VirtualBox is a virtual machine manager (version 4.3 or later) and can be downloaded from <https://www.virtualbox.org/wiki/Downloads>. It is needed to run the Data Torrent Sandbox.
-
-5.  *DataTorrent Sandbox* -- The sandbox can be downloaded from <https://www.datatorrent.com/download>. It is useful for testing simple applications since it contains Apache Hadoop and Data Torrent RTS 3.1.1 pre-installed with a time-limited Enterprise License. If you already installed the RTS Enterprise Edition (evaluation or production license) on a cluster, you can use that setup for deployment and testing instead of the sandbox.
-
-6.  (Optional) If you prefer to use an IDE (Integrated Development Environment) such as *NetBeans*, *Eclipse* or *IntelliJ*, install that as well.
-
-
-After installing these tools, make sure that the directories containing the executable files are in your PATH environment; for example, for the JDK executables like _java_ and _javac_, the directory might be something like `C:\\Program Files\\Java\\jdk1.7.0\_80\\bin`; for _git_ it might be `C:\\Program Files\\Git\\bin`; and for maven it might be `C:\\Users\\user\\Software\\apache-maven-3.3.3\\bin`. Open a console window and enter the command:
-
-    echo %PATH%
-
-to see the value of the `PATH` variable and verify that the above directories are present. If not, you can change its value clicking on the button at _Control Panel_ &#x21e8; _Advanced System Settings_ &#x21e8; _Advanced tab_ &#x21e8; _Environment Variables_.
-
-
-Now run the following commands and ensure that the output is something similar to that shown in the table below:
-
-
-<table>
-<colgroup>
-<col width="30%" />
-<col width="70%" />
-</colgroup>
-<tbody>
-<tr class="odd">
-<td align="left"><p>Command</p></td>
-<td align="left"><p>Output</p></td>
-</tr>
-<tr class="even">
-<td align="left"><p><tt>javac -version</tt></p></td>
-<td align="left"><p>javac 1.7.0_80</p></td>
-</tr>
-<tr class="odd">
-<td align="left"><p><tt>java -version</tt></p></td>
-<td align="left"><p>java version &quot;1.7.0_80&quot;</p>
-<p>Java(TM) SE Runtime Environment (build 1.7.0_80-b15)</p>
-<p>Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)</p></td>
-</tr>
-<tr class="even">
-<td align="left"><p><tt>git --version</tt></p></td>
-<td align="left"><p>git version 2.6.1.windows.1</p></td>
-</tr>
-<tr class="odd">
-<td align="left"><p><tt>mvn --version</tt></p></td>
-<td align="left"><p>Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T06:57:37-05:00)</p>
-<p>Maven home: C:\Users\ram\Software\apache-maven-3.3.3\bin\..</p>
-<p>Java version: 1.7.0_80, vendor: Oracle Corporation</p>
-<p>Java home: C:\Program Files\Java\jdk1.7.0_80\jre</p>
-<p>Default locale: en_US, platform encoding: Cp1252</p>
-<p>OS name: &quot;windows 8&quot;, version: &quot;6.2&quot;, arch: &quot;amd64&quot;, family: &quot;windows&quot;</p></td>
-</tr>
-</tbody>
-</table>
-
-
-To install the sandbox, first download it from <https://www.datatorrent.com/download> and import the downloaded file into VirtualBox. Once the import completes, you can select it and click the  Start button to start the sandbox.
-
-
-The sandbox is configured with 6GB RAM; if your development machine has 16GB or more, you can increase the sandbox RAM to 8GB or more using the VirtualBox console. This will yield better performance and support larger applications. Additionally, you can change the network adapter from **NAT** to **Bridged Adapter**; this will allow you to login to the sandbox from your host machine using an _ssh_ tool like **PuTTY** and also to transfer files to and from the host using `pscp` on Windows. Of course all such configuration must be done when when the sandbox is not running.
-
-
-You can choose to develop either directly on the sandbox or on your development machine. The advantage of the former is that most of the tools (e.g. _jdk_, _git_, _maven_) are pre-installed and also the package files created by your project are directly available to the Data Torrent tools such as  **dtManage** and **dtcli**. The disadvantage is that the sandbox is a memory-limited environment so running a memory-hungry tool like a Java IDE on it may starve other applications of memory.
-
-
-You can now use the maven archetype to create a basic Apache Apex project as follows: Put these lines in a Windows command file called, for example, `newapp.cmd` and run it:
-
-    @echo off
-    @rem Script for creating a new application
-    setlocal
-    mvn archetype:generate ^
-    -DarchetypeRepository=https://www.datatorrent.com/maven/content/repositories/releases ^
-      -DarchetypeGroupId=com.datatorrent ^
-      -DarchetypeArtifactId=apex-app-archetype ^
-      -DarchetypeVersion=3.1.1 ^
-      -DgroupId=com.example ^
-      -Dpackage=com.example.myapexapp ^
-      -DartifactId=myapexapp ^
-      -Dversion=1.0-SNAPSHOT
-    endlocal
-
-
-
-The caret (^) at the end of some lines indicates that a continuation line follows. When you run this file, the properties will be displayed and you will be prompted with `` Y: :``; just press **Enter** to complete the project generation.
-
-
-This command file also exists in the Data Torrent _examples_ repository which you can check out with:
-
-    git clone https://github.com/DataTorrent/examples
-
-You will find the script under `examples\tutorials\topnwords\scripts\newapp.cmd`.
-
-You can also, if you prefer, use an IDE to generate the project as described in Section 3 of [Application Packages](application_packages.md) but use the archetype version 3.1.1 instead of 3.0.0.
-
-
-When the run completes successfully, you should see a new directory named `myapexapp` containing a maven project for building a basic Apache Apex application. It includes 3 source files:**Application.java**,  **RandomNumberGenerator.java** and **ApplicationTest.java**. You can now build the application by stepping into the new directory and running the appropriate maven command:
-
-    cd myapexapp
-    mvn clean package -DskipTests
-
-The build should create the application package file `myapexapp\target\myapexapp-1.0-SNAPSHOT.apa`. This file can then be uploaded to the Data Torrent GUI tool on the sandbox (called **dtManage**) and launched  from there. It generates a stream of random numbers and prints them out, each prefixed by the string  `hello world: `.  If you built this package on the host, you can transfer it to the sandbox using the `pscp` tool bundled with **PuTTY** mentioned earlier.
-
-
-If you want to checkout the Apache Apex source repositories and build them, you can do so by running the script `build-apex.cmd` located in the same place in the examples repository described above. The source repositories contain more substantial demo applications and the associated source code. Alternatively, if you do not want to use the script, you can follow these simple manual steps:
-
-
-1.  Check out the source code repositories:
-
-        git clone https://github.com/apache/incubator-apex-core
-        git clone https://github.com/apache/incubator-apex-malhar
-
-2.  Switch to the appropriate release branch and build each repository:
-
-        pushd incubator-apex-core
-        git checkout release-3.1
-        mvn clean install -DskipTests
-        popd
-        pushd incubator-apex-malhar
-        git checkout release-3.1
-        mvn clean install -DskipTests
-        popd
-
-The `install` argument to the `mvn` command installs resources from each project to your local maven repository (typically `.m2/repository` under your home directory), and **not** to the system directories, so Administrator privileges are not required. The  `-DskipTests` argument skips running unit tests since they take a long time. If this is a first-time installation, it might take several minutes to complete because maven will download a number of associated plugins.
-
-After the build completes, you should see the demo application package files in the target directory under each demo subdirectory in `incubator-apex-malhar\demos\`.
-
-Linux
-------------------
-
-Most of the instructions for Linux (and other Unix-like systems) are similar to those for Windows described above, so we will just note the differences.
-
-
-The pre-requisites (such as _git_, _maven_, etc.) are the same as for Windows described above; please run the commands in the table and ensure that appropriate versions are present in your PATH environment variable (the command to display that variable is: `echo $PATH`).
-
-
-The maven archetype command is the same except that continuation lines use a backslash (``\``) instead of caret (``^``); the script for it is available in the same location and is named `newapp` (without the `.cmd` extension). The script to checkout and build the Apache Apex repositories is named `build-apex`.


[03/11] incubator-apex-core git commit: Migrating docs

Posted by th...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/docs/application_development.md
----------------------------------------------------------------------
diff --git a/docs/application_development.md b/docs/application_development.md
new file mode 100644
index 0000000..a76ad8a
--- /dev/null
+++ b/docs/application_development.md
@@ -0,0 +1,2934 @@
+Application Developer Guide
+===========================
+
+Real-time big data processing is not only important but has become
+critical for businesses which depend on accurate and timely analysis of
+their business data. A few businesses have yielded to very expensive
+solutions like building an in-house, real-time analytics infrastructure
+supported by an internal development team, or buying expensive
+proprietary software. A large number of businesses are dealing with the
+requirement just by trying to make Hadoop do their batch jobs in smaller
+iterations. Over the last few years, Hadoop has become ubiquitous in the
+big data processing space, replacing expensive proprietary hardware and
+software solutions for massive data processing with very cost-effective,
+fault-tolerant, open-sourced, and commodity-hardware-based solutions.
+While Hadoop has been a game changer for companies, it is primarily a
+batch-oriented system, and does not yet have a viable option for
+real-time data processing.  Most companies with real-time data
+processing end up having to build customized solutions in addition to
+their Hadoop infrastructure.
+
+ 
+
+The DataTorrent platform is designed to process massive amounts of
+real-time events natively in Hadoop. This can be event ingestion,
+processing, and aggregation for real-time data analytics, or can be
+real-time business logic decisioning such as cell tower load balancing,
+real-time ads bidding, or fraud detection.  The platform has the ability
+to repair itself in real-time (without data loss) if hardware fails, and
+adapt to changes in load by adding and removing computing resources
+automatically.
+
+
+
+DataTorrent is a native Hadoop application. It runs as a YARN
+(Hadoop 2.x) application and leverages Hadoop as a distributed operating
+system. All the basic distributed operating system capabilities of
+Hadoop like resource allocation (Resource Manager, distributed file system (HDFS),
+multi-tenancy, security, fault-tolerance, scalability, etc.
+are supported natively in all streaming applications.  Just as Hadoop
+for map-reduce handles all the details of the application allowing you
+to only focus on writing the application (the mapper and reducer
+functions), the platform handles all the details of streaming execution,
+allowing you to only focus on your business logic. Using the platform
+removes the need to maintain separate clusters for real-time
+applications.
+
+
+
+In the platform, building a streaming application can be extremely
+easy and intuitive.  The application is represented as a Directed
+Acyclic Graph (DAG) of computation units called *Operators* interconnected
+by the data-flow edges called  *Streams*. The operators process input
+streams and produce output streams. A library of common operators is
+provided to enable quick application development.  In case the desired
+processing is not available in the Operator Library, one can easily
+write a custom operator. We refer those interested in creating their own
+operators to the [Operator Development Guide](operator_development.md).
+
+Running A Test Application
+=======================================
+
+This chapter will help you with a quick start on running an
+application. If you are starting with the platform for the first time,
+it would be informative to open an existing application and see it run.
+Do the following steps to run the PI demo, which computes the value of
+PI  in a simple
+manner:
+
+1.  Open up platform files in your IDE (for example NetBeans, or Eclipse)
+2.  Open Demos project
+3.  Open Test Packages and run ApplicationTest.java in pi package
+4.  See the results in your system console
+
+
+
+Congratulations, you just ran your first real-time streaming demo
+:) This demo is very simple and has four operators. The first operator
+emits random integers between 0 to 30, 000. The second operator receives
+these coefficients and emits a hashmap with x and y values each time it
+receives two values. The third operator takes these values and computes
+x\*\*2+y\*\*2. The last operator counts how many computed values from
+the previous operator were less than or equal to 30, 000\*\*2. Assuming
+this count is N, then PI is computed as N/number of values received.
+Here is the code snippet for the PI application. This code populates the
+DAG. Do not worry about what each line does, we will cover these
+concepts later in this document.
+
+
+```java
+// Generates random numbers
+RandomEventGenerator rand = dag.addOperator("rand", new RandomEventGenerator());
+rand.setMinvalue(0);
+rand.setMaxvalue(30000);
+
+// Generates a round robin HashMap of "x" and "y"
+RoundRobinHashMap<String,Object> rrhm = dag.addOperator("rrhm", new RoundRobinHashMap<String, Object>());
+rrhm.setKeys(new String[] { "x", "y" });
+
+// Calculates pi from x and y
+JavaScriptOperator calc = dag.addOperator("picalc", new Script());
+calc.setPassThru(false);
+calc.put("i",0);
+calc.put("count",0);
+calc.addSetupScript("function pi() { if (x*x+y*y <= "+maxValue*maxValue+") { i++; } count++; return i / count * 4; }");
+calc.setInvoke("pi");
+dag.addStream("rand_rrhm", rand.integer_data, rrhm.data);
+dag.addStream("rrhm_calc", rrhm.map, calc.inBindings);
+
+// puts results on system console
+ConsoleOutputOperator console = dag.addOperator("console", new ConsoleOutputOperator());
+dag.addStream("rand_console",calc.result, console.input);
+```
+
+
+You can review the other demos and see what they do. The examples
+given in the Demos project cover various features of the platform and we
+strongly encourage you to read these to familiarize yourself with the
+platform. In the remaining part of this document we will go through
+details needed for you to develop and run streaming applications in
+Malhar.
+
+Test Application: Yahoo! Finance Quotes
+----------------------------------------------------
+
+The PI application was to
+get you started. It is a basic application and does not fully illustrate
+the features of the platform. For the purpose of describing concepts, we
+will consider the test application shown in Figure 1. The application
+downloads tick data from  [Yahoo! Finance](http://finance.yahoo.com)  and computes the
+following for four tickers, namely [IBM](http://finance.yahoo.com/q?s=IBM),
+[GOOG](http://finance.yahoo.com/q?s=GOOG), [YHOO](http://finance.yahoo.com/q?s=YHOO).
+
+1.  Quote: Consisting of last trade price, last trade time, and
+    total volume for the day
+2.  Per-minute chart data: Highest trade price, lowest trade
+    price, and volume during that minute
+3.  Simple Moving Average: trade price over 5 minutes
+
+
+Total volume must ensure that all trade volume for that day is
+added, i.e. data loss would result in wrong results. Charting data needs
+all the trades in the same minute to go to the same slot, and then on it
+starts afresh, so again data loss would result in wrong results. The
+aggregation for charting data is done over 1 minute. Simple moving
+average computes the average price over a 5 minute sliding window; it
+too would produce wrong results if there is data loss. Figure 1 shows
+the application with no partitioning.
+
+
+
+![](images/application_development/ApplicationDeveloperGuide.html-image00.png)
+
+
+
+The operator StockTickerInput: StockTickerInput[ ](http://docs.google.com/../apidocs/com/datatorrent/demos/yahoofinance/StockTickInput.html)is
+the input operator that reads live data from Yahoo! Finance once per
+interval (user configurable in milliseconds), and emits the price, the
+incremental volume, and the last trade time of each stock symbol, thus
+emulating real ticks from the exchange.  We utilize the Yahoo! Finance
+CSV web service interface.  For example:
+
+
+```
+$ GET 'http://download.finance.yahoo.com/d/quotes.csv?s=IBM,GOOG,AAPL,YHOO&f=sl1vt1'
+"IBM",203.966,1513041,"1:43pm"
+"GOOG",762.68,1879741,"1:43pm"
+"AAPL",444.3385,11738366,"1:43pm"
+"YHOO",19.3681,14707163,"1:43pm"
+```
+
+
+Among all the operators in Figure 1, StockTickerInput is the only
+operator that requires extra code because it contains a custom mechanism
+to get the input data.  Other operators are used unchanged from the
+Malhar library.
+
+
+Here is the class implementation for StockTickInput:
+
+
+```java
+package com.datatorrent.demos.yahoofinance;
+
+import au.com.bytecode.opencsv.CSVReader;
+import com.datatorrent.annotation.OutputPortFieldAnnotation;
+import com.datatorrent.api.Context.OperatorContext;
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.api.InputOperator;
+import com.datatorrent.lib.util.KeyValPair;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.*;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.cookie.CookiePolicy;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.params.DefaultHttpParams;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This operator sends price, volume and time into separate ports and calculates incremental volume.
+ */
+public class StockTickInput implements InputOperator
+{
+  private static final Logger logger = LoggerFactory.getLogger(StockTickInput.class);
+  /**
+   * Timeout interval for reading from server. 0 or negative indicates no timeout.
+   */
+  public int readIntervalMillis = 500;
+  /**
+   * The URL of the web service resource for the POST request.
+   */
+  private String url;
+  public String[] symbols;
+  private transient HttpClient client;
+  private transient GetMethod method;
+  private HashMap<String, Long> lastVolume = new HashMap<String, Long>();
+  private boolean outputEvenIfZeroVolume = false;
+  /**
+   * The output port to emit price.
+   */
+  @OutputPortFieldAnnotation(optional = true)
+  public final transient DefaultOutputPort<KeyValPair<String, Double>> price = new DefaultOutputPort<KeyValPair<String, Double>>();
+  /**
+   * The output port to emit incremental volume.
+   */
+  @OutputPortFieldAnnotation(optional = true)
+  public final transient DefaultOutputPort<KeyValPair<String, Long>> volume = new DefaultOutputPort<KeyValPair<String, Long>>();
+  /**
+   * The output port to emit last traded time.
+   */
+  @OutputPortFieldAnnotation(optional = true)
+  public final transient DefaultOutputPort<KeyValPair<String, String>> time = new DefaultOutputPort<KeyValPair<String, String>>();
+
+  /**
+   * Prepare URL from symbols and parameters. URL will be something like: http://download.finance.yahoo.com/d/quotes.csv?s=IBM,GOOG,AAPL,YHOO&f=sl1vt1
+   *
+   * @return the URL
+   */
+  private String prepareURL()
+  {
+    String str = "http://download.finance.yahoo.com/d/quotes.csv?s=";
+    for (int i = 0; i < symbols.length; i++) {
+      if (i != 0) {
+        str += ",";
+      }
+      str += symbols[i];
+    }
+    str += "&f=sl1vt1&e=.csv";
+    return str;
+  }
+
+  @Override
+  public void setup(OperatorContext context)
+  {
+    url = prepareURL();
+    client = new HttpClient();
+    method = new GetMethod(url);
+    DefaultHttpParams.getDefaultParams().setParameter("http.protocol.cookie-policy", CookiePolicy.BROWSER_COMPATIBILITY);
+  }
+
+  @Override
+  public void teardown()
+  {
+  }
+
+  @Override
+  public void emitTuples()
+  {
+
+    try {
+      int statusCode = client.executeMethod(method);
+      if (statusCode != HttpStatus.SC_OK) {
+        System.err.println("Method failed: " + method.getStatusLine());
+      }
+      else {
+        InputStream istream = method.getResponseBodyAsStream();
+        // Process response
+        InputStreamReader isr = new InputStreamReader(istream);
+        CSVReader reader = new CSVReader(isr);
+        List<String[]> myEntries = reader.readAll();
+        for (String[] stringArr: myEntries) {
+          ArrayList<String> tuple = new ArrayList<String>(Arrays.asList(stringArr));
+          if (tuple.size() != 4) {
+            return;
+          }
+          // input csv is <Symbol>,<Price>,<Volume>,<Time>
+          String symbol = tuple.get(0);
+          double currentPrice = Double.valueOf(tuple.get(1));
+          long currentVolume = Long.valueOf(tuple.get(2));
+          String timeStamp = tuple.get(3);
+          long vol = currentVolume;
+          // Sends total volume in first tick, and incremental volume afterwards.
+          if (lastVolume.containsKey(symbol)) {
+            vol -= lastVolume.get(symbol);
+          }
+
+          if (vol > 0 || outputEvenIfZeroVolume) {
+            price.emit(new KeyValPair<String, Double>(symbol, currentPrice));
+            volume.emit(new KeyValPair<String, Long>(symbol, vol));
+            time.emit(new KeyValPair<String, String>(symbol, timeStamp));
+            lastVolume.put(symbol, currentVolume);
+          }
+        }
+      }
+      Thread.sleep(readIntervalMillis);
+    }
+    catch (InterruptedException ex) {
+      logger.debug(ex.toString());
+    }
+    catch (IOException ex) {
+      logger.debug(ex.toString());
+    }
+  }
+
+  @Override
+  public void beginWindow(long windowId)
+  {
+  }
+
+  @Override
+  public void endWindow()
+  {
+  }
+
+  public void setOutputEvenIfZeroVolume(boolean outputEvenIfZeroVolume)
+  {
+	   this.outputEvenIfZeroVolume = outputEvenIfZeroVolume;
+  }
+
+}
+```
+
+
+
+The operator has three output ports that emit the price of the
+stock, the volume of the stock and the last trade time of the stock,
+declared as public member variables price, volume and  time of the class.  The tuple of the
+price output port is a key-value
+pair with the stock symbol being the key, and the price being the value.
+ The tuple of the volume output
+port is a key value pair with the stock symbol being the key, and the
+incremental volume being the value.  The tuple of the  time output port is a key value pair with the
+stock symbol being the key, and the last trade time being the
+value.
+
+
+
+Important: Since operators will be
+serialized, all input and output ports need to be declared transient
+because they are stateless and should not be serialized.
+
+
+
+The method setup(OperatorContext)
+contains the code that is necessary for setting up the HTTP
+client for querying Yahoo! Finance.
+
+
+
+Method emitTuples() contains
+the code that reads from Yahoo! Finance, and emits the data to the
+output ports of the operator.  emitTuples() will be called one or more times
+within one application window as long as time is allowed within the
+window.
+
+
+
+Note that we want to emulate the tick input stream by having
+incremental volume data with Yahoo! Finance data.  We therefore subtract
+the previous volume from the current volume to emulate incremental
+volume for each tick.
+
+
+
+The operator
+DailyVolume: This operator
+reads from the input port, which contains the incremental volume tuples
+from StockTickInput, and
+aggregates the data to provide the cumulative volume.  It uses the
+library class  SumKeyVal&lt;K,V&gt; provided in math package.  In this case,
+SumKeyVal&lt;String,Long&gt;, where K is the stock symbol, V is the
+aggregated volume, with cumulative
+set to true. (Otherwise if  cumulativewas set to false, SumKeyVal would
+provide the sum for the application window.)  Malhar provides a number
+of built-in operators for simple operations like this so that
+application developers do not have to write them.  More examples to
+follow. This operator assumes that the application restarts before the
+market opens every day.
+
+
+
+The operator Quote:
+This operator has three input ports, which are price (from
+StockTickInput), daily_vol (from
+Daily Volume), and time (from
+ StockTickInput).  This operator
+just consolidates the three data items and and emits the consolidated
+data.  It utilizes the class ConsolidatorKeyVal&lt;K&gt; from the
+stream package.
+
+
+
+The operator HighLow: This operator reads from the input port,
+which contains the price tuples from StockTickInput, and provides the high and the
+low price within the application window.  It utilizes the library class
+ RangeKeyVal&lt;K,V&gt; provided
+in the math package. In this case,
+RangeKeyVal&lt;String,Double&gt;.
+
+
+
+The operator MinuteVolume:
+This operator reads from the input port, which contains the
+volume tuples from StockTickInput,
+and aggregates the data to provide the sum of the volume within one
+minute.  Like the operator  DailyVolume, this operator also uses
+SumKeyVal&lt;String,Long&gt;, but
+with cumulative set to false.  The
+Application Window is set to one minute. We will explain how to set this
+later.
+
+
+
+The operator Chart:
+This operator is very similar to the operator Quote, except that it takes inputs from
+High Low and  Minute Vol and outputs the consolidated tuples
+to the output port.
+
+
+
+The operator PriceSMA:
+SMA stands for - Simple Moving Average. It reads from the
+input port, which contains the price tuples from StockTickInput, and
+provides the moving average price of the stock.  It utilizes
+SimpleMovingAverage&lt;String,Double&gt;, which is provided in the
+ multiwindow package.
+SimpleMovingAverage keeps track of the data of the previous N
+application windows in a sliding manner.  For each end window event, it
+provides the average of the data in those application windows.
+
+
+
+The operator Console:
+This operator just outputs the input tuples to the console
+(or stdout).  In this example, there are four console operators, which connect to the output
+of  Quote, Chart, PriceSMA and VolumeSMA.  In
+practice, they should be replaced by operators that use the data to
+produce visualization artifacts like charts.
+
+
+
+Connecting the operators together and constructing the
+DAG: Now that we know the
+operators used, we will create the DAG, set the streaming window size,
+instantiate the operators, and connect the operators together by adding
+streams that connect the output ports with the input ports among those
+operators.  This code is in the file  YahooFinanceApplication.java. Refer to Figure 1
+again for the graphical representation of the DAG.  The last method in
+the code, namely getApplication(),
+does all that.  The rest of the methods are just for setting up the
+operators.
+
+
+
+```java
+package com.datatorrent.demos.yahoofinance;
+
+import com.datatorrent.api.ApplicationFactory;
+import com.datatorrent.api.Context.OperatorContext;
+import com.datatorrent.api.DAG;
+import com.datatorrent.api.Operator.InputPort;
+import com.datatorrent.lib.io.ConsoleOutputOperator;
+import com.datatorrent.lib.math.RangeKeyVal;
+import com.datatorrent.lib.math.SumKeyVal;
+import com.datatorrent.lib.multiwindow.SimpleMovingAverage;
+import com.datatorrent.lib.stream.ConsolidatorKeyVal;
+import com.datatorrent.lib.util.HighLow;
+import org.apache.hadoop.conf.Configuration;
+
+/**
+ * Yahoo! Finance application demo. <p>
+ *
+ * Get Yahoo finance feed and calculate minute price range, minute volume, simple moving average of 5 minutes.
+ */
+public class Application implements StreamingApplication
+{
+  private int streamingWindowSizeMilliSeconds = 1000; // 1 second (default is 500ms)
+  private int appWindowCountMinute = 60;   // 1 minute
+  private int appWindowCountSMA = 5 * 60;  // 5 minute
+
+  /**
+   * Get actual Yahoo finance ticks of symbol, last price, total daily volume, and last traded price.
+   */
+  public StockTickInput getStockTickInputOperator(String name, DAG dag)
+  {
+    StockTickInput oper = dag.addOperator(name, StockTickInput.class);
+    oper.readIntervalMillis = 200;
+    return oper;
+  }
+
+  /**
+   * This sends total daily volume by adding volumes from each ticks.
+   */
+  public SumKeyVal<String, Long> getDailyVolumeOperator(String name, DAG dag)
+  {
+    SumKeyVal<String, Long> oper = dag.addOperator(name, new SumKeyVal<String, Long>());
+    oper.setType(Long.class);
+    oper.setCumulative(true);
+    return oper;
+  }
+
+  /**
+   * Get aggregated volume of 1 minute and send at the end window of 1 minute.
+   */
+  public SumKeyVal<String, Long> getMinuteVolumeOperator(String name, DAG dag, int appWindowCount)
+  {
+    SumKeyVal<String, Long> oper = dag.addOperator(name, new SumKeyVal<String, Long>());
+    oper.setType(Long.class);
+    oper.setEmitOnlyWhenChanged(true);
+dag.getOperatorMeta(name).getAttributes().put(OperatorContext.APPLICATION_WINDOW_COUNT,appWindowCount);
+    return oper;
+  }
+
+  /**
+   * Get High-low range for 1 minute.
+   */
+  public RangeKeyVal<String, Double> getHighLowOperator(String name, DAG dag, int appWindowCount)
+  {
+    RangeKeyVal<String, Double> oper = dag.addOperator(name, new RangeKeyVal<String, Double>());
+    dag.getOperatorMeta(name).getAttributes().put(OperatorContext.APPLICATION_WINDOW_COUNT,appWindowCount);
+    oper.setType(Double.class);
+    return oper;
+  }
+
+  /**
+   * Quote (Merge price, daily volume, time)
+   */
+  public ConsolidatorKeyVal<String,Double,Long,String,?,?> getQuoteOperator(String name, DAG dag)
+  {
+    ConsolidatorKeyVal<String,Double,Long,String,?,?> oper = dag.addOperator(name, new ConsolidatorKeyVal<String,Double,Long,String,Object,Object>());
+    return oper;
+  }
+
+  /**
+   * Chart (Merge minute volume and minute high-low)
+   */
+  public ConsolidatorKeyVal<String,HighLow,Long,?,?,?> getChartOperator(String name, DAG dag)
+  {
+    ConsolidatorKeyVal<String,HighLow,Long,?,?,?> oper = dag.addOperator(name, new ConsolidatorKeyVal<String,HighLow,Long,Object,Object,Object>());
+    return oper;
+  }
+
+  /**
+   * Get simple moving average of price.
+   */
+  public SimpleMovingAverage<String, Double> getPriceSimpleMovingAverageOperator(String name, DAG dag, int appWindowCount)
+  {
+    SimpleMovingAverage<String, Double> oper = dag.addOperator(name, new SimpleMovingAverage<String, Double>());
+    oper.setWindowSize(appWindowCount);
+    oper.setType(Double.class);
+    return oper;
+  }
+
+  /**
+   * Get console for output.
+   */
+  public InputPort<Object> getConsole(String name, /*String nodeName,*/ DAG dag, String prefix)
+  {
+    ConsoleOutputOperator oper = dag.addOperator(name, ConsoleOutputOperator.class);
+    oper.setStringFormat(prefix + ": %s");
+    return oper.input;
+  }
+
+  /**
+   * Create Yahoo Finance Application DAG.
+   */
+  @Override
+  public void populateDAG(DAG dag, Configuration conf)
+  {
+    dag.getAttributes().put(DAG.STRAM_WINDOW_SIZE_MILLIS,streamingWindowSizeMilliSeconds);
+
+    StockTickInput tick = getStockTickInputOperator("StockTickInput", dag);
+    SumKeyVal<String, Long> dailyVolume = getDailyVolumeOperator("DailyVolume", dag);
+    ConsolidatorKeyVal<String,Double,Long,String,?,?> quoteOperator = getQuoteOperator("Quote", dag);
+
+    RangeKeyVal<String, Double> highlow = getHighLowOperator("HighLow", dag, appWindowCountMinute);
+    SumKeyVal<String, Long> minuteVolume = getMinuteVolumeOperator("MinuteVolume", dag, appWindowCountMinute);
+    ConsolidatorKeyVal<String,HighLow,Long,?,?,?> chartOperator = getChartOperator("Chart", dag);
+
+    SimpleMovingAverage<String, Double> priceSMA = getPriceSimpleMovingAverageOperator("PriceSMA", dag, appWindowCountSMA);
+       DefaultPartitionCodec<String, Double> codec = new DefaultPartitionCodec<String, Double>();
+    dag.setInputPortAttribute(highlow.data, PortContext.STREAM_CODEC, codec);
+    dag.setInputPortAttribute(priceSMA.data, PortContext.STREAM_CODEC, codec);
+    dag.addStream("price", tick.price, quoteOperator.in1, highlow.data, priceSMA.data);
+    dag.addStream("vol", tick.volume, dailyVolume.data, minuteVolume.data);
+    dag.addStream("time", tick.time, quoteOperator.in3);
+    dag.addStream("daily_vol", dailyVolume.sum, quoteOperator.in2);
+
+    dag.addStream("quote_data", quoteOperator.out, getConsole("quoteConsole", dag, "QUOTE"));
+
+    dag.addStream("high_low", highlow.range, chartOperator.in1);
+    dag.addStream("vol_1min", minuteVolume.sum, chartOperator.in2);
+    dag.addStream("chart_data", chartOperator.out, getConsole("chartConsole", dag, "CHART"));
+
+    dag.addStream("sma_price", priceSMA.doubleSMA, getConsole("priceSMAConsole", dag, "Price SMA"));
+
+    return dag;
+  }
+
+}
+```
+
+
+
+Note that we also set a user-specific sliding window for SMA that
+keeps track of the previous N data points.  Do not confuse this with the
+attribute APPLICATION_WINDOW_COUNT.
+
+In the rest of this chapter we will run through the process of
+running this application. We assume that  you are familiar with details
+of your Hadoop infrastructure. For installation
+details please refer to the [Installation Guide](installation.md).
+
+
+Running a Test Application
+-----------------------------------------
+
+We will now describe how to run the yahoo
+finance application described above in different modes
+(local mode, single node on Hadoop, and multi-nodes on Hadoop).
+
+
+The platform runs streaming applications under the control of a
+light-weight Streaming Application Manager (STRAM). Each application has
+its own instance of STRAM. STRAM launches the application and
+continually provides run time monitoring, analysis, and takes action
+such as load scaling or outage recovery as needed.  We will discuss
+STRAM in more detail in the next chapter.
+
+
+
+The instructions below assume that the platform was installed in a
+directory &lt;INSTALL_DIR&gt; and the command line interface (CLI) will
+be used to launch the demo application. An application can be run in
+[local mode](#h.3dy6vkm)[ ](#h.3dy6vkm)(in IDE or from command line) or on a  [Hadoop cluster](#h.1t3h5sf) [.](#h.1t3h5sf)
+
+
+
+To start the dtCli run
+
+    <INSTALL_DIR>/bin/dtcli
+
+The command line prompt appears.  To start the application in local mode (the actual version number in the file name may differ)
+
+    dt> launch -local <INSTALL_DIR>/yahoo-finance-demo-3.2.0-SNAPSHOT.apa
+
+To terminate the application in local mode, enter Ctrl-C
+
+Tu run the application on the Hadoop cluster (the actual version
+number in the file name may differ)
+
+    dt> launch <INSTALL_DIR>/yahoo-finance-demo-3.2.0-SNAPSHOT.apa
+
+
+To stop the application running in Hadoop, terminate it in the dtCli:
+
+    dt> kill-app
+
+
+
+Executing the application in either mode includes the following
+steps. At a top level, STRAM (Streaming Application Manager) validates
+the application (DAG), translates the logical plan to the physical plan
+and then launches the execution engine. The mode determines the
+resources needed and how how they are used.
+
+Local Mode
+-----------------------
+
+In local mode, the application is run as a single-process with multiple threads. Although a
+few Hadoop classes are needed, there is no dependency on a Hadoop
+cluster or Hadoop services. The local file system is used in place of
+HDFS. This mode allows a quick run of an application in a single process
+sandbox, and hence is the most suitable to debug and analyze the
+application logic. This mode is recommended for developing the
+application and can be used for running applications within the IDE for
+functional testing purposes. Due to limited resources and lack  of
+scalability an application running in this single process mode is more
+likely to encounter throughput bottlenecks. A distributed cluster is
+recommended for benchmarking and production testing.
+
+Hadoop Cluster
+---------------------------
+
+In this section we discuss various Hadoop cluster setups.
+
+### Single Node Cluster
+
+In a single node Hadoop cluster all services are deployed on a
+single server (a developer can use his/her development machine as a
+single node cluster). The platform does not distinguish between a single
+or multi-node setup and behaves exactly the same in both cases.
+
+
+
+In this mode, the resource manager, name node, data node, and node
+manager occupy one process each. This is an example of running a
+streaming application as a multi-process application on the same server.
+With prevalence of fast, multi-core systems, this mode is effective for
+debugging, fine tuning, and generic analysis before submitting the job
+to a larger Hadoop cluster. In this mode, execution uses the Hadoop
+services and hence is likely to identify issues that are related to the
+Hadoop environment (such issues will not be uncovered in local mode).
+The throughput will obviously not be as high as on a multi-node Hadoop
+cluster. Additionally, since each container (i.e. Java process) requires
+a significant amount of memory, you will be able to run a much smaller
+number of containers than on a multi-node cluster.
+
+### Multi-Node Cluster
+
+In a multi-node Hadoop cluster all the services of Hadoop are
+typically distributed across multiple nodes in a production or
+production-level test environment. Upon launch the application is
+submitted to the Hadoop cluster and executes as a  multi-processapplication on multiple nodes.
+
+
+
+Before you start deploying, testing and troubleshooting your
+application on a cluster, you should ensure that Hadoop (version 2.2.0
+or later) is properly installed and
+you have basic skills for working with it.
+
+------------------------------------------------------------------------
+
+
+
+
+
+Apache Apex Platform Overview
+========================================
+
+Streaming Computational Model
+------------------------------------------
+
+In this chapter, we describe the the basics of the real-time streaming platform and its computational model.
+
+
+The platform is designed to enable completely asynchronous real time computations done in as unblocked a way as possible with
+minimal overhead .
+
+
+
+Applications running in the platform are represented by a Directed
+Acyclic Graph (DAG) made up of  operators and streams. All computations
+are done in memory on arrival of
+the input data, with an option to save the output to disk (HDFS) in a
+non-blocking way. The data that flows between operators consists of
+atomic data elements. Each data element along with its type definition
+(henceforth called  schema) is
+called a tuple. An application is a
+design of the flow of these tuples to and from
+the appropriate compute units to enable the computation of the final
+desired results. A message queue (henceforth called
+ buffer server) manages tuples streaming
+between compute units in different processes.This server keeps track of
+all consumers, publishers, partitions, and enables replay. More
+information is given in later section.
+
+
+
+The streaming application is monitored by a decision making entity
+called STRAM (streaming application
+manager). STRAM is designed to be a light weight
+controller that has minimal but sufficient interaction with the
+application. This is done via periodic heartbeats. The
+STRAM does the initial launch and periodically analyzes the system
+metrics to decide if any run time action needs to be taken.
+
+
+
+A fundamental building block for the streaming platform
+is the concept of breaking up a stream into equal finite time slices
+called streaming windows. Each window contains the ordered
+set of tuples in that time slice. A typical duration of a window is 500
+ms, but can be configured per application (the Yahoo! Finance
+application configures this value in the  properties.xml file to be 1000ms = 1s). Each
+window is preceded by a begin_window event and is terminated by an
+end_window event, and is assigned
+a unique window ID. Even though the platform performs computations at
+the tuple level, bookkeeping is done at the window boundary, making the
+computations within a window an atomic event in the platform.  We can
+think of each window as an  atomic
+micro-batch of tuples, to be processed together as one
+atomic operation (See Figure 2).  
+
+
+
+This atomic batching allows the platform to avoid the very steep
+per tuple bookkeeping cost and instead has a manageable per batch
+bookkeeping cost. This translates to higher throughput, low recovery
+time, and higher scalability. Later in this document we illustrate how
+the atomic micro-batch concept allows more efficient optimization
+algorithms.
+
+
+
+The platform also has in-built support for
+application windows.  An application window is part of the
+application specification, and can be a small or large multiple of the
+streaming window.  An example from our Yahoo! Finance test application
+is the moving average, calculated over a sliding application window of 5
+minutes which equates to 300 (= 5 \* 60) streaming windows.
+
+
+
+Note that these two window concepts are distinct.  A streaming
+window is an abstraction of many tuples into a higher atomic event for
+easier management.  An application window is a group of consecutive
+streaming windows used for data aggregation (e.g. sum, average, maximum,
+minimum) on a per operator level.
+
+![](images/application_development/ApplicationDeveloperGuide.html-image02.png)
+
+Alongside the platform, a set of
+predefined, benchmarked standard library operator templates is provided
+for ease of use and rapid development of application. These
+operators are open sourced to Apache Software Foundation under the
+project name “Malhar” as part of our efforts to foster community
+innovation. These operators can be used in a DAG as is, while others
+have  [properties](#h.32hioqz)
+[ ](#h.32hioqz)that can be set to specify the
+desired computation. Those interested in details, should refer to
+[Apex Malhar Operator Library](apex_malhar.md)
+.
+
+
+
+The platform is a Hadoop YARN native
+application. It runs in a Hadoop cluster just like any
+other YARN application (MapReduce etc.) and is designed to seamlessly
+integrate with rest of Hadoop technology stack. It leverages Hadoop as
+much as possible and relies on it as its distributed operating system.
+Hadoop dependencies include resource management, compute/memory/network
+allocation, HDFS, security, fault tolerance, monitoring, metrics,
+multi-tenancy, logging etc. Hadoop classes/concepts are reused as much
+as possible.  The aim is to enable enterprises
+to leverage their existing Hadoop infrastructure for real time streaming
+applications. The platform is designed to scale with big
+data applications and scale with Hadoop.
+
+
+
+A streaming application is an asynchronous execution of
+computations across distributed nodes. All computations are done in
+parallel on a distributed cluster. The computation model is designed to
+do as many parallel computations as possible in a non-blocking fashion.
+The task of monitoring of the entire application is done on (streaming)
+window boundaries with a streaming window as an atomic entity. A window
+completion is a quantum of work done. There is no assumption that an
+operator can be interrupted at precisely a particular tuple or window.
+
+
+
+
+An operator itself also
+cannot assume or predict the exact time a tuple that it emitted would
+get consumed by downstream operators. The operator processes the tuples
+it gets and simply emits new tuples based on its business logic. The
+only guarantee it has is that the upstream operators are processing
+either the current or some later window, and the downstream operator is
+processing either the current or some earlier window. The completion of
+a window (i.e. propagation of the  end_window event through an operator) in any
+operator guarantees that all upstream operators have finished processing
+this window. Thus, the end_window event is blocking on an operator
+with multiple outputs, and is a synchronization point in the DAG. The
+ begin_window event does not have
+any such restriction, a single begin_window event from any upstream operator
+triggers the operator to start processing tuples.
+
+Streaming Application Manager (STRAM)
+--------------------------------------------------
+
+Streaming Application Manager (STRAM) is the Hadoop YARN native
+application master. STRAM is the first process that is activated upon
+application launch and orchestrates the streaming application on the
+platform. STRAM is a lightweight controller process. The
+responsibilities of STRAM include
+
+1.  Running the Application
+
+    *  Read the logical plan of the application (DAG) submitted by the client
+    *  Validate the logical plan
+    *  Translate the logical plan into a physical plan, where certain operators may  be partitioned (i.e. replicated) to multiple operators for  handling load.
+    *  Request resources (Hadoop containers) from Resource Manager,
+        per physical plan
+    *  Based on acquired resources and application attributes, create
+        an execution plan by partitioning the DAG into fragments,
+        each assigned to different containers.
+    *  Executes the application by deploying each fragment to
+        its container. Containers then start stream processing and run
+        autonomously, processing one streaming window after another. Each
+        container is represented as an instance of the  StreamingContainer class, which updates
+        STRAM via the heartbeat protocol and processes directions received
+        from STRAM.
+
+2.  Continually monitoring the application via heartbeats from each StreamingContainer
+3.  Collecting Application System Statistics and Logs
+4.  Logging all application-wide decisions taken
+5.  Providing system data on the state of the application via a  Web Service.
+6.  Supporting [Fault Tolerance](#h.2nusc19)
+
+    a.  Detecting a node outage
+    b.  Requesting a replacement resource from the Resource Manager
+        and scheduling state restoration for the streaming operators
+    c.  Saving state to Zookeeper
+
+7.  Supporting [Dynamic
+    Partitioning](#h.3hv69ve)[:](#h.3hv69ve) Periodically
+    evaluating the SLA and modifying the physical plan if required
+    (logical plan does not change).
+8.  Enabling [Security](#h.3q5sasy)[:](#h.3q5sasy) Distributing
+    security tokens for distributed components of the execution engine
+    and securing web service requests.
+9.  Enabling [Dynamic  modification](#h.40ew0vw)[ ](#h.40ew0vw)of
+    DAG: In the future, we intend to allow for user initiated
+    modification of the logical plan to allow for changes to the
+    processing logic and functionality.
+
+
+
+An example of the Yahoo! Finance Quote application scheduled on a
+cluster of 5 Hadoop containers (processes) is shown in Figure 3.
+
+![](images/application_development/ApplicationDeveloperGuide.html-image01.png)
+
+
+
+An example for the translation from a logical plan to a physical
+plan and an execution plan for a subset of the application is shown in
+Figure 4.
+
+
+
+![](images/application_development/ApplicationDeveloperGuide.html-image04.png)
+
+
+
+
+
+Hadoop Components
+------------------------------
+
+In this section we cover some aspects of Hadoop that your
+streaming application interacts with. This section is not meant to
+educate the reader on Hadoop, but just get the reader acquainted with
+the terms. We strongly advise readers to learn Hadoop from other
+sources.
+
+A streaming application runs as a native Hadoop 2.2 application.
+Hadoop 2.2 does not differentiate between a map-reduce job and other
+applications, and hence as far as Hadoop is concerned, the streaming
+application is just another job. This means that your application
+leverages all the bells and whistles Hadoop provides and is fully
+supported within Hadoop technology stack. The platform is responsible
+for properly integrating itself with the relevant components of Hadoop
+that exist today and those that may emerge in the future
+
+
+
+All investments that leverage multi-tenancy (for example quotas
+and queues), security (for example kerberos), data flow integration (for
+example copying data in-out of HDFS), monitoring, metrics collections,
+etc. will require no changes when streaming applications run on
+Hadoop.
+
+### YARN
+
+[YARN](http://hadoop.apache.org/docs/current/hadoop-yarn/hadoop-yarn-site)is
+the core library of Hadoop 2.2 that is tasked with resource management
+and works as a distributed application framework. In this section we
+will walk through Yarn's components. In Hadoop 2.2, the old jobTracker
+has been replaced by a combination of ResourceManager (RM) and
+ApplicationMaster (AM).
+
+#### Resource Manager (RM)
+
+[ResourceManager](http://hadoop.apache.org/docs/current/hadoop-yarn/hadoop-yarn-site/YARN.html)(RM)
+manages all the distributed resources. It allocates and arbitrates all
+the slots and the resources (cpu, memory, network) of these slots. It
+works with per-node NodeManagers (NMs) and per-application
+ApplicationMasters (AMs). Currently memory usage is monitored by RM; in
+upcoming releases it will have CPU as well as network management. RM is
+shared by map-reduce and streaming applications. Running streaming
+applications requires no changes in the RM.
+
+#### Application Master (AM)
+
+The AM is the watchdog or monitoring process for your application
+and has the responsibility of negotiating resources with RM and
+interacting with NodeManagers to get the allocated containers started.
+The AM is the starting point of your application and is considered user
+code (not system Hadoop code). The AM itself runs in one container. All
+resource management within the application are managed by the AM. This
+is a critical feature for Hadoop 2.2 where tasks done by jobTracker in
+Hadoop 1.0 have been distributed allowing Hadoop 2.2 to scale much
+beyond Hadoop 1.0. STRAM is a native YARN ApplicationManager.
+
+#### Node Managers (NM)
+
+There is one [NodeManager](http://hadoop.apache.org/docs/current/hadoop-yarn/hadoop-yarn-site/YARN.html)(NM)
+per node in the cluster. All the containers (i.e. processes) on that
+node are monitored by the NM. It takes instructions from RM and manages
+resources of that node as per RM instructions. NMs interactions are same
+for map-reduce and for streaming applications. Running streaming
+applications requires no changes in the NM.
+
+#### RPC Protocol
+
+Communication among RM, AM, and NM is done via the Hadoop RPC
+protocol. Streaming applications use the same protocol to send their
+data. No changes are needed in RPC support provided by Hadoop to enable
+communication done by components of your application.
+
+### HDFS
+
+Hadoop includes a highly fault tolerant, high throughput
+distributed file system ([HDFS](http://hadoop.apache.org/docs/r1.0.4/hdfs_design.html)).
+It runs on commodity hardware, and your streaming application will, by
+default, use it. There is no difference between files created by a
+streaming application and those created by map-reduce.
+
+Developing An Application
+======================================
+
+In this chapter we describe the methodology to develop an
+application using the Realtime Streaming Platform. The platform was
+designed to make it easy to build and launch sophisticated streaming
+applications with the developer having to deal only with the
+application/business logic. The platform deals with details of where to
+run what operators on which servers and how to correctly route streams
+of data among them.
+
+Development Process
+--------------------------------
+
+While the platform does not mandate a specific methodology or set
+of development tools, we have recommendations to maximize productivity
+for the different phases of application development.
+
+#### Design
+
+-   Identify common, reusable operators. Use a library
+    if possible.
+-   Identify scalability and performance requirements before
+    designing the DAG.
+-   Leverage attributes that the platform supports for scalability
+    and performance.
+-   Use operators that are benchmarked and tested so that later
+    surprises are minimized. If you have glue code, create appropriate
+    unit tests for it.
+-   Use THREAD_LOCAL locality for high throughput streams. If all
+    the operators on that stream cannot fit in one container,
+    try NODE_LOCAL locality. Both THREAD_LOCAL and
+    NODE_LOCAL streams avoid the Network Interface Card (NIC)
+    completly. The former uses intra-process communication to also avoid
+    serialization-deserialization overhead.
+-   The overall throughput and latencies are are not necessarily
+    correlated to the number of operators in a simple way -- the
+    relationship is more nuanced. A lot depends on how much work
+    individual operators are doing, how many are able to operate in
+    parallel, and how much data is flowing through the arcs of the DAG.
+    It is, at times, better to break a computation down into its
+    constituent simple parts and then stitch them together via streams
+    to better utilize the compute resources of the cluster. Decide on a
+    per application basis the fine line between complexity of each
+    operator vs too many streams. Doing multiple computations in one
+    operator does save network I/O, while operators that are too complex
+    are hard to maintain.
+-   Do not use operators that depend on the order of two streams
+    as far as possible. In such cases behavior is not idempotent.
+-   Persist key information to HDFS if possible; it may be useful
+    for debugging later.
+-   Decide on an appropriate fault tolerance mechanism. If some
+    data loss is acceptable, use the at-most-once mechanism as it has
+    fastest recovery.
+
+#### Creating New Project
+
+Please refer to the [Apex Application Packages](application_packages.md) for
+the basic steps for creating a new project.
+
+#### Writing the application code
+
+Preferably use an IDE (Eclipse, Netbeans etc.) that allows you to
+manage dependencies and assists with the Java coding. Specific benefits
+include ease of managing operator library jar files, individual operator
+classes, ports and properties. It will also highlight and assist to
+rectify issues such as type mismatches when adding streams while
+typing.
+
+#### Testing
+
+Write test cases with JUnit or similar test framework so that code
+is tested as it is written. For such testing, the DAG can run in local
+mode within the IDE. Doing this may involve writing mock input or output
+operators for the integration points with external systems. For example,
+instead of reading from a live data stream, the application in test mode
+can read from and write to files. This can be done with a single
+application DAG by instrumenting a test mode using settings in the
+configuration that is passed to the application factory
+interface.
+
+Good test coverage will not only eliminate basic validation errors
+such as missing port connections or property constraint violations, but
+also validate the correct processing of the data. The same tests can be
+re-run whenever the application or its dependencies change (operator
+libraries, version of the platform etc.)
+
+#### Running an application
+
+The platform provides a commandline tool called dtcli for managing applications (launching,
+killing, viewing, etc.). This tool was already discussed above briefly
+in the section entitled Running the Test Application. It will introspect
+the jar file specified with the launch command for applications (classes
+that implement ApplicationFactory) or property files that define
+applications. It will also deploy the dependency jar files from the
+application package to the cluster.
+
+
+
+Dtcli can run the application in local mode (i.e. outside a
+cluster). It is recommended to first run the application in local mode
+in the development environment before launching on the Hadoop cluster.
+This way some of the external system integration and correct
+functionality of the application can be verified in an easier to debug
+environment before testing distributed mode.
+
+
+
+For more details on CLI please refer to the [dtCli Guide](dtcli.md).
+
+Application API
+----------------------------
+
+This section introduces the API to write a streaming application.
+The work involves connecting operators via streams to form the logical
+DAG. The steps are
+
+1.  Instantiate an application (DAG)
+
+2.  (Optional) Set Attributes
+    *  Assign application name
+    *  Set any other attributes as per application requirements
+
+3.  Create/re-use and instantiate operators
+    *  Assign operator name that is unique within the  application
+    *  Declare schema upfront for each operator (and thereby its  [ports](#h.ihv636)[)](#h.ihv636)
+    *  (Optional) Set [properties](#h.32hioqz)[ ](#h.32hioqz) and [attributes](#h.41mghml)[ ](#h.41mghml) on the dag as per specification
+    *  Connect ports of operators via streams
+        *  Each stream connects one output port of an operator to one or  more input ports of other operators.
+        *  (Optional) Set attributes on the streams
+
+4.  Test the application.
+
+
+
+There are two methods to create an application, namely Java, and
+Properties file. Java API is for applications being developed by humans,
+and properties file (Hadoop like) is more suited for DAGs generated by
+tools.
+
+### Java API
+
+The Java API is the most common way to create a streaming
+application. It is meant for application developers who prefer to
+leverage the features of Java, and the ease of use and enhanced
+productivity provided by IDEs like NetBeans or Eclipse. Using Java to
+specify the application provides extra validation abilities of Java
+compiler, such as compile time checks for type safety at the time of
+writing the code. Later in this chapter you can read more about
+validation support in the platform.
+
+The developer specifies the streaming application by implementing
+the ApplicationFactory interface, which is how platform tools (CLI etc.)
+recognize and instantiate applications. Here we show how to create a
+Yahoo! Finance application that streams the last trade price of a ticker
+and computes the high and low price in every 1 min window. Run above
+ test application to execute the
+DAG in local mode within the IDE.
+
+
+
+Let us revisit how the Yahoo! Finance test application constructs the DAG:
+
+
+
+```java
+public class Application implements StreamingApplication
+{
+
+  ...
+
+  @Override
+  public void populateDAG(DAG dag, Configuration conf)
+  {
+    dag.getAttributes().attr(DAG.STRAM_WINDOW_SIZE_MILLIS).set(streamingWindowSizeMilliSeconds);
+
+    StockTickInput tick = getStockTickInputOperator("StockTickInput", dag);
+    SumKeyVal<String, Long> dailyVolume = getDailyVolumeOperator("DailyVolume", dag);
+    ConsolidatorKeyVal<String,Double,Long,String,?,?> quoteOperator = getQuoteOperator("Quote", dag);
+
+    RangeKeyVal<String, Double> highlow = getHighLowOperator("HighLow", dag, appWindowCountMinute);
+    SumKeyVal<String, Long> minuteVolume = getMinuteVolumeOperator("MinuteVolume", dag, appWindowCountMinute);
+    ConsolidatorKeyVal<String,HighLow,Long,?,?,?> chartOperator = getChartOperator("Chart", dag);
+
+    SimpleMovingAverage<String, Double> priceSMA = getPriceSimpleMovingAverageOperator("PriceSMA", dag, appWindowCountSMA);
+
+    dag.addStream("price", tick.price, quoteOperator.in1, highlow.data, priceSMA.data);
+    dag.addStream("vol", tick.volume, dailyVolume.data, minuteVolume.data);
+    dag.addStream("time", tick.time, quoteOperator.in3);
+    dag.addStream("daily_vol", dailyVolume.sum, quoteOperator.in2);
+
+    dag.addStream("quote_data", quoteOperator.out, getConsole("quoteConsole", dag, "QUOTE"));
+
+    dag.addStream("high_low", highlow.range, chartOperator.in1);
+    dag.addStream("vol_1min", minuteVolume.sum, chartOperator.in2);
+    dag.addStream("chart_data", chartOperator.out, getConsole("chartConsole", dag, "CHART"));
+
+    dag.addStream("sma_price", priceSMA.doubleSMA, getConsole("priceSMAConsole", dag, "Price SMA"));
+
+    return dag;
+  }
+}
+```
+
+
+
+
+### Property File API
+
+The platform also supports specification of a DAG via a property
+file. The aim here to make it easy for tools to create and run an
+application. This method of specification does not have the Java
+compiler support of compile time check, but since these applications
+would be created by software, they should be correct by construction.
+The syntax is derived from Hadoop properties and should be easy for
+folks who are used to creating software that integrated with
+Hadoop.
+
+
+
+Create an application (DAG): myApplication.properties
+
+
+```
+# input operator that reads from a file
+dt.operator.inputOp.classname=com.acme.SampleInputOperator
+dt.operator.inputOp.fileName=somefile.txt
+
+# output operator that writes to the console
+dt.operator.outputOp.classname=com.acme.ConsoleOutputOperator
+
+# stream connecting both operators
+dt.stream.inputStream.source=inputOp.outputPort
+dt.stream.inputStream.sinks=outputOp.inputPort
+```
+
+
+
+Above snippet is intended to convey the basic idea of specifying
+the DAG without using Java. Operators would come from a predefined
+library and referenced in the specification by class name and port names
+(obtained from the library providers documentation or runtime
+introspection by tools). For those interested in details, see later
+sections and refer to the  Operation and
+Installation Guide mentioned above.
+
+### Attributes
+
+Attributes impact the runtime behavior of the application. They do
+not impact the functionality. An example of an attribute is application
+name. Setting it changes the application name. Another example is
+streaming window size. Setting it changes the streaming window size from
+the default value to the specified value. Users cannot add new
+attributes, they can only choose from the ones that come packaged and
+pre-supported by the platform. Details of attributes are covered in the
+ Operation and Installation
+Guide.
+
+Operators
+----------------------
+
+Operators are basic compute units.
+Operators process each incoming tuple and emit zero or more tuples on
+output ports as per the business logic. The data flow, connectivity,
+fault tolerance (node outage), etc. is taken care of by the platform. As
+an operator developer, all that is needed is to figure out what to do
+with the incoming tuple and when (and which output port) to send out a
+particular output tuple. Correctly designed operators will most likely
+get reused. Operator design needs care and foresight. For details, refer
+to the  [Operator Developer Guide](operator_development.md). As an application developer you need to connect operators
+in a way that it implements your business logic. You may also require
+operator customization for functionality and use attributes for
+performance/scalability etc.
+
+
+
+All operators process tuples asynchronously in a distributed
+cluster. An operator cannot assume or predict the exact time a tuple
+that it emitted will get consumed by a downstream operator. An operator
+also cannot predict the exact time when a tuple arrives from an upstream
+operator. The only guarantee is that the upstream operators are
+processing the current or a future window, i.e. the windowId of upstream
+operator is equals or exceeds its own windowId. Conversely the windowId
+of a downstream operator is less than or equals its own windowId. The
+end of a window operation, i.e. the API call to endWindow on an operator
+requires that all upstream operators have finished processing this
+window. This means that completion of processing a window propagates in
+a blocking fashion through an operator. Later sections provides more
+details on streams and data flow of tuples.
+
+
+
+Each operator has a unique name within the DAG as provided by the
+user. This is the name of the operator in the logical plan. The name of
+the operator in the physical plan is an integer assigned to it by STRAM.
+These integers are use the sequence from 1 to N, where N is total number
+of physically unique operators in the DAG.  Following the same rule,
+each partitioned instance of a logical operator has its own integer as
+an id. This id along with the Hadoop container name uniquely identifies
+the operator in the execution plan of the DAG. The logical names and the
+physical names are required for web service support. Operators can be
+accessed via both names. These same names are used while interacting
+with  dtcli to access an operator.
+Ideally these names should be self-descriptive. For example in Figure 1,
+the node named “Daily volume” has a physical identifier of 2.
+
+### Operator Interface
+
+Operator interface in a DAG consists of [ports](#h.ihv636)[,](#h.ihv636) [properties](#h.32hioqz)[,](#h.32hioqz) and
+ [attributes](#h.41mghml)
+[.](#h.41mghml) Operators interact with other
+components of the DAG via ports. Functional behavior of the operators
+can be customized via parameters. Run time performance and physical
+instantiation is controlled by attributes. Ports and parameters are
+fields (variables) of the Operator class/object, while attributes are
+meta information that is attached to the operator object via an
+AttributeMap. An operator must have at least one port. Properties are
+optional. Attributes are provided by the platform and always have a
+default value that enables normal functioning of operators.
+
+#### Ports
+
+Ports are connection points by which an operator receives and
+emits tuples. These should be transient objects instantiated in the
+operator object, that implement particular interfaces. Ports should be
+transient as they contain no state. They have a pre-defined schema and
+can only be connected to other ports with the same schema. An input port
+needs to implement the interface  Operator.InputPort and
+interface Sink. A default
+implementation of these is provided by the abstract class DefaultInputPort. An output port needs to
+implement the interface  Operator.OutputPort. A default implementation
+of this is provided by the concrete class DefaultOutputPort. These two are a quick way to
+implement the above interfaces, but operator developers have the option
+of providing their own implementations.
+
+
+
+Here are examples of an input and an output port from the operator
+Sum.
+
+
+
+```java
+@InputPortFieldAnnotation(name = "data")
+public final transient DefaultInputPort<V> data = new DefaultInputPort<V>() {
+  @Override
+  public void process(V tuple)
+  {
+  	...
+  }
+}
+@OutputPortFieldAnnotation(optional=true)
+public final transient DefaultOutputPort<V> sum = new DefaultOutputPort<V>(){ … };
+```
+
+
+
+
+The process call is in the Sink interface. An emit on an output
+port is done via emit(tuple) call. For the above example it would be
+sum.emit(t), where the type of t is the generic parameter V.
+
+
+
+There is no limit on how many ports an operator can have. However
+any operator must have at least one port. An operator with only one port
+is called an Input Adapter if it has no input port and an Output Adapter
+if it has no output port. These are special operators needed to get/read
+data from outside system/source into the application, or push/write data
+into an outside system/sink. These could be in Hadoop or outside of
+Hadoop. These two operators are in essence gateways for the streaming
+application to communicate with systems outside the application.
+
+
+
+Port connectivity can be validated during compile time by adding
+PortFieldAnnotations shown above. By default all ports have to be
+connected, to allow a port to go unconnected, you need to add
+“optional=true” to the annotation.
+
+
+
+Attributes can be specified for ports that affect the runtime
+behavior. An example of an attribute is parallel partition that specifes
+a parallel computation flow per partition. It is described in detail in
+the [Parallel
+Partitions](#h.3vac5uf)[ ](#h.3vac5uf)section.
+Another example is queue capacity that specifies the buffer size for the
+port. Details of attributes are covered in  Operation and Installation Guide.
+
+#### Properties
+
+Properties are the abstractions by which functional behavior of an
+operator can be customized. They should be non-transient objects
+instantiated in the operator object. They need to be non-transient since
+they are part of the operator state and re-construction of the operator
+object from its checkpointed state must restore the operator to the
+desired state. Properties are optional, i.e. an operator may or may not
+have properties; they are part of user code and their values are not
+interpreted by the platform in any way.
+
+
+
+All non-serializable objects should be declared transient.
+Examples include sockets, session information, etc. These objects should
+be initialized during setup call, which is called every time the
+operator is initialized.
+
+#### Attributes
+
+Attributes are values assigned to the operators that impact
+run-time. This includes things like the number of partitions, at most
+once or at least once or exactly once recovery modes, etc. Attributes do
+not impact functionality of the operator. Users can change certain
+attributes in runtime. Users cannot add attributes to operators; they
+are pre-defined by the platform. They are interpreted by the platform
+and thus cannot be defined in user created code (like properties).
+Details of attributes are covered in  [Configuration Guide](configuration.md).
+
+### Operator State
+
+The state of an operator is defined as the data that it transfers
+from one window to a future window. Since the computing model of the
+platform is to treat windows like micro-batches, the operator state can
+be [checkpointed](#h.3mzq4wv)[ ](#h.3mzq4wv)every
+Nth window, or every T units of time, where T is significantly greater
+than the streaming window.  When an operator is checkpointed, the entire
+object is written to HDFS.  The larger the amount of state in an
+operator, the longer it takes to recover from a failure. A stateless
+operator can recover much quicker than a stateful one. The needed
+windows are preserved by the upstream buffer server and are used to
+recompute the lost windows, and also rebuild the buffer server in the
+current container.
+
+
+
+The distinction between Stateless and Stateful is based solely on
+the need to transfer data in the operator from one window to the next.
+The state of an operator is independent of the number of ports.
+
+#### Stateless
+
+A Stateless operator is defined as one where no data is needed to
+be kept at the end of every window. This means that all the computations
+of a window can be derived from all the tuples the operator receives
+within that window. This guarantees that the output of any window can be
+reconstructed by simply replaying the tuples that arrived in that
+window. Stateless operators are more efficient in terms of fault
+tolerance, and cost to achieve SLA.
+
+#### Stateful
+
+A Stateful operator is defined as one where data is needed to be
+stored at the end of a window for computations occurring in later
+window; a common example is the computation of a sum of values in the
+input tuples.
+
+### Operator API
+
+The Operator API consists of methods that operator developers may
+need to override. In this section we will discuss the Operator APIs from
+the point of view of an application developer. Knowledge of how an
+operator works internally is critical for writing an application. Those
+interested in the details should refer to  Malhar Operator Developer Guide.
+
+
+
+The APIs are available in three modes, namely Single Streaming
+Window, Sliding Application Window, and Aggregate Application Window.
+These are not mutually exclusive, i.e. an operator can use single
+streaming window as well as sliding application window. A physical
+instance of an operator is always processing tuples from a single
+window. The processing of tuples is guaranteed to be sequential, no
+matter which input port the tuples arrive on.
+
+
+
+In the later part of this section we will evaluate three common
+uses of streaming windows by applications. They have different
+characteristics and implications on optimization and recovery mechanisms
+(i.e. algorithm used to recover a node after outage) as discussed later
+in the section.
+
+#### Streaming Window
+
+Streaming window is atomic micro-batch computation period. The API
+methods relating to a streaming window are as follows
+
+
+
+```java
+public void process(<tuple_type> tuple) // Called on the input port on which the tuple arrives
+public void beginWindow(long windowId) // Called at the start of the window as soon as the first begin_window tuple arrives
+public void endWindow() // Called at the end of the window after end_window tuples arrive on all input ports
+public void setup(OperatorContext context) // Called once during initialization of the operator
+public void teardown() // Called once when the operator is being shutdown
+```
+
+
+A tuple can be emitted in any of the three streaming run-time
+calls, namely beginWindow, process, and endWindow but not in setup or
+teardown.
+
+#### Aggregate Application Window
+
+An operator with an aggregate window is stateful within the
+application window timeframe and possibly stateless at the end of that
+application window. An size of an aggregate application window is an
+operator attribute and is defined as a multiple of the streaming window
+size. The platform recognizes this attribute and optimizes the operator.
+The beginWindow, and endWindow calls are not invoked for those streaming
+windows that do not align with the application window. For example in
+case of streaming window of 0.5 second and application window of 5
+minute, an application window spans 600 streaming windows (5\*60\*2 =
+600). At the start of the sequence of these 600 atomic streaming
+windows, a beginWindow gets invoked, and at the end of these 600
+streaming windows an endWindow gets invoked. All the intermediate
+streaming windows do not invoke beginWindow or endWindow. Bookkeeping,
+node recovery, stats, UI, etc. continue to work off streaming windows.
+For example if operators are being checkpointed say on an average every
+30th window, then the above application window would have about 20
+checkpoints.
+
+#### Sliding Application Window
+
+A sliding window is computations that requires previous N
+streaming windows. After each streaming window the Nth past window is
+dropped and the new window is added to the computation. An operator with
+sliding window is a stateful operator at end of any window. The sliding
+window period is an attribute and is a multiple of streaming window. The
+platform recognizes this attribute and leverages it during bookkeeping.
+A sliding aggregate window with tolerance to data loss does not have a
+very high bookkeeping cost. The cost of all three recovery mechanisms,
+ at most once (data loss tolerant),
+at least once (data loss
+intolerant), and exactly once (data
+loss intolerant and no extra computations) is same as recovery
+mechanisms based on streaming window. STRAM is not able to leverage this
+operator for any extra optimization.
+
+### Single vs Multi-Input Operator
+
+A single-input operator by definition has a single upstream
+operator, since there can only be one writing port for a stream.  If an
+operator has a single upstream operator, then the beginWindow on the
+upstream also blocks the beginWindow of the single-input operator. For
+an operator to start processing any window at least one upstream
+operator has to start processing that window. A multi-input operator
+reads from more than one upstream ports. Such an operator would start
+processing as soon as the first begin_window event arrives. However the
+window would not close (i.e. invoke endWindow) till all ports receive
+end_window events for that windowId. Thus the end of a window is a
+blocking event. As we saw earlier, a multi-input operator is also the
+point in the DAG where windows of all upstream operators are
+synchronized. The windows (atomic micro-batches) from a faster (or just
+ahead in processing) upstream operators are queued up till the slower
+upstream operator catches up. STRAM monitors such bottlenecks and takes
+corrective actions. The platform ensures minimal delay, i.e processing
+starts as long as at least one upstream operator has started
+processing.
+
+### Recovery Mechanisms
+
+Application developers can set any of the recovery mechanisms
+below to deal with node outage. In general, the cost of recovery depends
+on the state of the operator, while data integrity is dependant on the
+application. The mechanisms are per window as the platform treats
+windows as atomic compute units. Three recovery mechanisms are
+supported, namely
+
+-   At-least-once: All atomic batches are processed at least once.
+    No data loss occurs.
+-   At-most-once: All atomic batches are processed at most once.
+    Data loss is possible; this is the most efficient setting.
+-   Exactly-once: All atomic batches are processed exactly once.
+    No data loss occurs; this is the least efficient setting since
+    additional work is needed to ensure proper semantics.
+
+At-least-once is the default. During a recovery event, the
+operator connects to the upstream buffer server and asks for windows to
+be replayed. At-least-once and exactly-once mechanisms start from its
+checkpointed state. At-most-once starts from the next begin-window
+event.
+
+
+
+Recovery mechanisms can be specified per Operator while writing
+the application as shown below.
+
+
+```java
+Operator o = dag.addOperator(“operator”, …);
+dag.setAttribute(o,  OperatorContext.PROCESSING_MODE,  ProcessingMode.AT_MOST_ONCE);
+```
+
+
+Also note that once an operator is attributed to AT_MOST_ONCE,
+all the operators downstream to it have to be AT_MOST_ONCE. The client
+will give appropriate warnings or errors if that’s not the case.
+
+
+
+Details are explained in the chapter on Fault Tolerance
+below[.](#h.2nusc19)
+
+Streams
+--------------------
+
+A stream is a connector
+(edge) abstraction, and is a fundamental building block of the platform.
+A stream consists of tuples that flow from one port (called the
+output port) to one or more ports
+on other operators (called  input ports) another -- so note a potentially
+confusing aspect of this terminology: tuples enter a stream through its
+output port and leave via one or more input ports. A stream has the
+following characteristics
+
+-   Tuples are always delivered in the same order in which they
+    were emitted.
+-   Consists of a sequence of windows one after another. Each
+    window being a collection of in-order tuples.
+-   A stream that connects two containers passes through a
+    buffer server.
+-   All streams can be persisted (by default in HDFS).
+-   Exactly one output port writes to the stream.
+-   Can be read by one or more input ports.
+-   Connects operators within an application, not outside
+    an application.
+-   Has an unique name within an application.
+-   Has attributes which act as hints to STRAM.
+-   Streams have four modes, namely in-line, in-node, in-rack,
+    and other. Modes may be overruled (for example due to lack
+    of containers). They are defined as follows:
+
+    -   THREAD_LOCAL: In the same thread, uses thread
+        stack (intra-thread). This mode can only be used for a downstream
+        operator which has only one input port connected; also called
+        in-line.
+    -   CONTAINER_LOCAL: In the same container (intra-process); also
+        called in-container.
+    -   NODE_LOCAL: In the same Hadoop node (inter processes, skips
+        NIC); also called in-node.
+    -   RACK_LOCAL: On nodes in the same rack; also called
+        in-rack.
+    -   unspecified: No guarantee. Could be anywhere within the
+        cluster
+
+
+
+An example of a stream declaration is given below
+
+
+
+```java
+DAG dag = new DAG();
+ …
+dag.addStream("views", viewAggregate.sum, cost.data).setLocality(CONTAINER_LOCAL); // A container local  stream
+dag.addStream(“clicks”, clickAggregate.sum, rev.data); // An example of unspecified locality
+```
+
+
+The platform guarantees in-order delivery of tuples in a stream.
+STRAM views each stream as collection of ordered windows. Since no tuple
+can exist outside a window, a replay of a stream consists of replay of a
+set of windows. When multiple input ports read the same stream, the
+execution plan of a stream ensures that each input port is logically not
+blocked by the reading of another input port. The schema of a stream is
+same as the schema of the tuple.
+
+
+
+In a stream all tuples emitted by an operator in a window belong
+to that window. A replay of this window would consists of an in-order
+replay of all the tuples. Thus the tuple order within a stream is
+guaranteed. However since an operator may receive multiple streams (for
+example an operator with two input ports), the order of arrival of two
+tuples belonging to different streams is not guaranteed. In general in
+an asynchronous distributed architecture this is expected. Thus the
+operator (specially one with multiple input ports) should not depend on
+the tuple order from two streams. One way to cope with this
+indeterminate order, if necessary, is to wait to get all the tuples of a
+window and emit results in endWindow call. All operator templates
+provided as part of  [standard operator template
+library](#h.3ep43zb) [ ](#h.3ep43zb)follow
+these principles.
+
+
+
+A logical stream gets partitioned into physical streams each
+connecting the partition to the upstream operator. If two different
+attributes are needed on the same stream, it should be split using
+StreamDuplicator operator.
+
+
+
+Modes of the streams are critical for performance. An in-line
+stream is the most optimal as it simply delivers the tuple as-is without
+serialization-deserialization. Streams should be marked
+container_local, specially in case where there is a large tuple volume
+between two operators which then on drops significantly. Since the
+setLocality call merely provides a hint, STRAM may ignore it. An In-node
+stream is not as efficient as an in-line one, but it is clearly better
+than going off-node since it still avoids the potential bottleneck of
+the network card.
+
+
+
+THREAD_LOCAL and CONTAINER_LOCAL streams do not use a buffer
+server as this stream is in a single process. The other two do.
+
+Validating an Application
+--------------------------------------
+
+The platform provides various ways of validating the application
+specification and data input. An understanding of these checks is very
+important for an application developer since it affects productivity.
+Validation of an application is done in three phases, namely
+
+
+
+1.  Compile Time: Caught during application development, and is
+    most cost effective. These checks are mainly done on declarative
+    objects and leverages the Java compiler. An example is checking that
+    the schemas specified on all ports of a stream are
+    mutually compatible.
+2.  Initialization Time: When the application is being
+    initialized, before submitting to Hadoop. These checks are related
+    to configuration/context of an application, and are done by the
+    logical DAG builder implementation. An example is the checking that
+    all non-optional ports are connected to other ports.
+3.  Run Time: Validations done when the application is running.
+    This is the costliest of all checks. These are checks that can only
+    be done at runtime as they involve data. For example divide by 0
+    check as part of business logic.
+
+### Compile Time
+
+Compile time validations apply when an application is specified in
+Java code and include all checks that can be done by Java compiler in
+the development environment (including IDEs like NetBeans or Eclipse).
+Examples include
+
+1.  Schema Validation: The tuples on ports are POJO (plain old
+    java objects) and compiler checks to ensure that all the ports on a
+    stream have the same schema.
+2.  Stream Check: Single Output Port and at least one Input port
+    per stream. A stream can only have one output port writer. This is
+    part of the addStream api. This
+    check ensures that developers only connect one output port to
+    a stream. The same signature also ensures that there is at least one
+    input port for a stream
+3.  Naming: Compile time checks ensures that applications
+    components operators, streams are named
+
+### Initialization/Instantiation Time
+
+Initialization time validations include various checks that are
+done post compile, and before the application starts running in a
+cluster (or local mode). These are mainly configuration/contextual in
+nature. These checks are as critical to proper functionality of the
+application as the compile time validations.
+
+
+
+Examples include
+
+-   [JavaBeans Validation](http://docs.oracle.com/javaee/6/tutorial/doc/gircz.html):
+    Examples include
+
+    -   @Max(): Value must be less than or equal to the number
+    -   @Min(): Value must be greater than or equal to the
+        number
+    -   @NotNull: The value of the field or property must not be
+        null
+    -   @Pattern(regexp = “....”): Value must match the regular
+        expression
+    -   Input port connectivity: By default, every non-optional input
+        port must be connected. A port can be declared optional by using an
+        annotation:     @InputPortFieldAnnotation(name = "...", optional
+        = true)
+    -   Output Port Connectivity: Similar. The annotation here is:    
+        @OutputPortFieldAnnotation(name = "...", optional = true)
+
+-   Unique names in application scope: Operators, streams, must have
+    unique names.
+-   Cycles in the dag: DAG cannot have a cycle.
+-   Unique names in operator scope: Ports, properties, annotations
+    must have unique names.
+-   One stream per port: A port can connect to only one stream.
+    This check applies to input as well as output ports even though an
+    output port can technically write to two streams. If you must have
+    two streams originating from a single output port, use  a streamDuplicator operator.
+-   Application Window Period: Has to be an integral multiple the
+    streaming window period.
+
+### Run Time
+
+Run time checks are those that are done when the application is
+running. The real-time streaming platform provides rich run time error
+handling mechanisms. The checks are exclusively done by the application
+business logic, but the platform allows applications to count and audit
+these. Some of these features are in the process of development (backend
+and UI) and this section will be updated as they are developed. Upon
+completion examples will be added to  [demos](#h.upglbi) [t](#h.upglbi)o
+illustrate these.
+
+
+
+Error ports are output ports with error annotations. Since they
+are normal ports, they can be monitored and tuples counted, persisted
+and counts shown in the UI.
+
+------------------------------------------------------------------------
+
+
+
+
+
+Multi-Tenancy and Security
+=======================================
+
+Hadoop is a multi-tenant distributed operating system. Security is
+an intrinsic element of multi-tenancy as without it a cluster cannot be
+reasonably be shared among enterprise applications. Streaming
+applications follow all multi-tenancy security models used in Hadoop as
+they are native Hadoop applications. For details refer to the
+[Operation and Installation
+Guide](https://www.datatorrent.com/docs/guides/OperationandInstallationGuide.html)
+.
+
+Security
+---------------------
+
+The platform includes Kerberos support. Both access points, namely
+STRAM and Bufferserver are secure. STRAM passes the token over to
+StreamingContainer, which then gives it to the Bufferserver. The most
+important aspect for an application developer is to note that STRAM is
+the single point of access to ensure security measures are taken by all
+components of the platform.
+
+Resource Limits
+----------------------------
+
+Hadoop enforces quotas on resources. This includes hard-disk (name
+space and total disk quota) as well as priority queues for schedulers.
+The platform uses Hadoop resource limits to manage a streaming
+application. In addition network I/O quotas can be enforced. An operator
+can be dynamically partitioned if it reaches its resource limits; these
+limits may be expressed in terms of throughput, latency, or just
+aggregate resource utilization of a container.
+
+
+
+
+
+------------------------------------------------------------------------
+
+
+
+
+
+Scalability and Partitioning
+=========================================
+
+Scalability is a foundational element of this platform and is a
+building block for an eco-system where big-data meets real-time.
+Enterprises need to continually meet SLA as data grows. Without the
+ability to scale as load grows, or new applications with higher loads
+come to fruition, enterprise grade SLA cannot be met. A big issue with
+the streaming application space is that, it is not just about high load,
+but also the fluctuations in it. There is no way to guarantee future
+load requirements and there is a big difference between high and low
+load within a day for the same feed. Traditional streaming platforms
+solve these two cases by simply throwing more hardware at the
+problem.
+
+
+
+Daily spikes are managed by ensuring enough hardware for peak
+load, which then idles during low load, and future needs are handled by
+a very costly re-architecture, or investing heavily in building a
+scalable distributed operating system. Another salient and often
+overlooked cost is the need to manage SLA -- let’s call it  buffer capacity. Since this means computing the
+peak load within required time, that translates to allocating enough
+resources over and above peak load as daily peaks fluctuate. For example
+an average peak load of 100 resource units (cpu and/or memory and/or
+network) may mean allocating about 200 resource units to be safe. A
+distributed cluster that cannot dynamically scale up and down, in effect
+pays buffer capacity per application. Another big aspect of streaming
+applications is that the load is not just ingestion rate, more often
+than not, the internal operators produce lot more events than the
+ingestion rate. For example a dimensional data (with, say  d dimensions) computation needs 2\*d -1 computations per ingested event. A lot
+of applications have over 10 dimensions, i.e over 1000 computations per
+incoming event and these need to be distributed across the cluster,
+thereby causing an explosion in the throughput (events/sec) that needs
+to be managed.
+
+
+
+The platform is designed to handle such cases at a very low cost.
+The platform scales linearly with Hadoop. If applications need more
+resources, the enterprise can simply add more commodity nodes to Hadoop
+without any downtime, and the Hadoop native platform will take care of
+the rest. If some nodes go bad, these can be removed without downtime.
+The daily peaks and valleys in the load are managed by the platform by
+dynamically scaling at the peak and then giving the resources back to
+Hadoop during low load. This means that a properly designed Hadoop
+cluster does several things for enterprises: (a) reduces the cost of
+hardware due to use of commodity hardware (b) shares buffer capacity
+across all applications as peaks of all applications may not align and
+(c) raises the average CPU usage on a 24x7 basis. As a general design
+this is similar to scale that a map-reduce application can deliver. In
+the following sections of this chapter we will see how this is
+done.
+
+Partitioning
+-------------------------
+
+If all tuples sent through the stream(s) that are connected to the
+input port(s) of an operator in the DAG are received by a single
+physical instance of that operator, that operator can become a
+performance bottleneck. This leads to scalability issues when
+throughput, memory, or CPU needs exceed the processing capacity of that
+single instance.
+
+
+
+To address the problem, the platform offers the capability to
+partition the inflow of data so that it is divided across multiple
+physical instances of a logical operator in the DAG. There are two
+functional ways to partition
+
+-   Load balance: Incoming load is simply partitioned
+    into stream(s) that go to separate instances of physical operators
+    and scalability is achieved via adding more physical operators. Each
+    tuple is sent to physical operator (partition) based on a
+    round-robin or other similar algorithm. This scheme scales linearly.
+    A lot of key based computations can load balance in the platform due
+    to the ability to insert  Unifiers. For many computations, the
+    endWindow and Unifier setup is similar to the combiner and reducer
+    mechanism in a Map-Reduce computation.
+-   Sticky Key: The key assertion is that distribution of tuples
+    are sticky, i.e the data with
+    same key will always be processed by the same physical operator, no
+    matter how many times it is sent through the stream. This stickiness
+    will continue even if the number of partitions grows dynamically and
+    can eventually be leveraged for advanced features like
+    bucket testing. How this is accomplished and what is required to
+    develop compliant operators will be explained below.
+
+
+
+We plan to add more partitioning mechanisms proactively to the
+platform over time as needed by emerging usage patterns. The aim is to
+allow enterprises to be able to focus on their business logic, and
+significantly reduce the cost of operability. As an enabling technology
+for managing high loads, this platform provides enterprises with a
+significant innovative edge. Scalability and Partitioning is a
+foundational building block for this platform.
+
+### Sticky Partition vs Round Robin
+
+As noted above, partitioning via sticky key is data aware but
+round-robin partitioning is not. An example for non-sticky load
+balancing would be round robin distribution over multiple instances,
+where for example a tuple stream of  A, A,
+A with 3 physical operator
+instances would result in processing of a single A by each of the instances, In contrast, sticky
+partitioning means that exactly one instance of the operators will
+process all of the  Atuples if they
+fall into the same bucket, while B
+may be processed by another operator. Data aware mapping of
+tuples to partitions (similar to distributed hash table) is accomplished
+via Stream Codecs. In later sections we would show how these two
+approaches can be used in combination.
+
+### Stream Codec
+
+The platform does not make assumptions about the tuple
+type, it could be any Java object. The operator developer knows what
+tuple type an input port expects and is capable of processing. Each
+input port has a stream codec  associated thatdefines how data is serialized when transmitted over a socket
+stream; it also defines another
+function that computes the partition hash key for the tuple. The engine
+uses that key to determine which physical instance(s)  (for a
+partitioned operator) receive that  tuple. For this to work, consistent hashing is required.
+The default codec uses the Java Object\#hashCode function, which is
+sufficient for basic types such as Integer, String etc. It will also
+work with custom tuple classes as long as they implement hashCode
+appropriately. Reliance on hashCode may not work when generic containers
+are used that do not hash the actual data, such as standard collection
+classes (HashMap etc.), in which case a custom stream codec must be
+assigned to the input port.
+
+### Static Partitioning
+
+DAG designers can specify at design time how they would like
+certain operators to be partitioned. STRAM then instantiates the DAG
+with the physical plan which adheres to the partitioning scheme defined
+by the design. This plan is the initial partition of the application. In
+other words, Static Partitioning is used to tell STRAM to compute the
+physical DAG from a logical DAG once, without taking into consideration
+runtime states or loads of various operators.
+
+### Dynamic Partitioning
+
+In streaming applications the load changes during the day, thus
+creating situations where the number of partitioned operator instances
+needs to adjust dynamically. The load can be measured in terms of
+processing within the DAG based on throughput, or latency, or
+considerations in external system components (time based etc.) that the
+platform may not be aware of. Whatever the trigger, the resource
+requirement for the current processing needs to be adjusted at run-time.
+The platform may detect that operator instances are over or under
+utilized and may need to dynamically adjust the number of instances on
+the fly. More instances of a logical operator may be required (partition
+split) or underutilized operator instances may need decommissioning
+(partition merge). We refer to either of the changes as dynamic
+partitioning. The default partitioning scheme supports split and merge
+of 

<TRUNCATED>


[11/11] incubator-apex-core git commit: Incorporate conf package doc into app package doc

Posted by th...@apache.org.
Incorporate conf package doc into app package doc


Project: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/commit/333313b5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/tree/333313b5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/diff/333313b5

Branch: refs/heads/APEXCORE-293
Commit: 333313b5926cddaa3272b1551e89eff4903b501c
Parents: 269fbb2
Author: David Yan <da...@datatorrent.com>
Authored: Thu Mar 3 13:33:47 2016 -0800
Committer: David Yan <da...@datatorrent.com>
Committed: Thu Mar 3 13:36:53 2016 -0800

----------------------------------------------------------------------
 docs/application_packages.md | 199 ++++++++++++++++++++++++++++++++------
 1 file changed, 172 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/333313b5/docs/application_packages.md
----------------------------------------------------------------------
diff --git a/docs/application_packages.md b/docs/application_packages.md
index 3a83d46..6c6a807 100644
--- a/docs/application_packages.md
+++ b/docs/application_packages.md
@@ -1,23 +1,25 @@
-Apache Apex Application Packages
-================================
+Apache Apex Application and Configuration Packages
+==================================================
+
+# Application Packages
 
 An Apache Apex Application Package is a zip file that contains all the
 necessary files to launch an application in Apache Apex. It is the
 standard way for assembling and sharing an Apache Apex application.
 
-# Requirements
+## Requirements
 
 You will need have the following installed:
 
 1. Apache Maven 3.0 or later (for assembling the App Package)
 2. Apache Apex 3.2.0 or later (for launching the App Package in your cluster)
 
-# Creating Your First Apex App Package
+## Creating Your First Apex App Package
 
 You can create an Apex Application Package using your Linux command
 line, or using your favorite IDE.
 
-## Using Command Line
+### Using Command Line
 
 First, change to the directory where you put your projects, and create
 an Apex application project using Maven by running the following
@@ -78,7 +80,7 @@ directory as target/mydtapp-1.0-SNAPSHOT.apa. You will be able to use
 that App Package file to launch this sample application in your actual
 Apex installation.
 
-## Using IDE
+### Using IDE
 
 Alternatively, you can do the above steps all within your IDE.  For example, in IDEA IntelliJ, first make sure you have the "Maven Integration" plugin enabled (Use File -\> Settings \-> Plugins).  Then select File -\> New -\> Project.  Choose “Maven”, and check “Create from archetype” in the dialog box, as shown.
 
@@ -113,12 +115,12 @@ project, with a default unit test.  You can run the unit test, make code
 changes or make dependency changes within your IDE.  The procedure for
 other IDEs, like Eclipse or NetBeans, is similar.
 
-# Writing Your Own App Package
+## Writing Your Own App Package
 
 
 Please refer to the [Creating Apps](http://docs.datatorrent.com/create/) on the basics on how to write an Apache Apex application.  In your AppPackage project, you can add custom operators (refer to [Operator Development Guide](operator_development.md), project dependencies, default and required configuration properties, pre-set configurations and other metadata.
 
-## Adding (and removing) project dependencies
+### Adding (and removing) project dependencies
 
 Under the project, you can add project dependencies in pom.xml, or do it
 through your IDE.  Here’s the section that describes the dependencies in
@@ -192,7 +194,7 @@ warnings similar to the following:
 This is a bug in early versions of Maven 3.  The dependency exclusion is
 still valid and it is safe to ignore these warnings.
 
-## Application Configuration
+### Application Configuration
 
 A configuration file can be used to configure an application.  Different
 kinds of configuration parameters can be specified. They are application
@@ -214,7 +216,7 @@ as name value pairs, in XML format, like the following.
 </configuration>
 ```
 
-## Application attributes
+### Application attributes
 
 Application attributes are used to specify the platform behavior for the
 application. They can be specified using the parameter
@@ -236,7 +238,7 @@ identifying the attribute. The constants are defined in
 com.datatorrent.api.Context.DAGContext and the different attributes can
 be specified in the format described above.
 
-## Operator attributes
+### Operator attributes
 
 Operator attributes are used to specify the platform behavior for the
 operator. They can be specified using the parameter
@@ -263,7 +265,7 @@ identifying the attribute. The constants are defined in
 com.datatorrent.api.Context.OperatorContext and the different attributes
 can be specified in the format described above.
 
-## Operator properties
+### Operator properties
 
 Operators can be configured using operator specific properties. The
 properties can be specified using the parameter
@@ -290,7 +292,7 @@ setHost. The method is called using JAVA reflection and the property
 value is passed as an argument. In the above example the method setHost
 will be called on the “redis” operator with “127.0.0.1” as the argument.
 
-## Port attributes
+### Port attributes
 Port attributes are used to specify the platform behavior for input and
 output ports. They can be specified using the parameter ```dt.operator.<operator-name>.inputport.<port-name>.attr.<attribute>```
 for input port and ```dt.operator.<operator-name>.outputport.<port-name>.attr.<attribute>```
@@ -320,7 +322,7 @@ instead of “intputport”. A generic keyword “port” can be used to specify
 either an input or an output port. It is useful in the wildcard
 specification described below.
 
-## Stream properties
+### Stream properties
 
 Streams can be configured using stream properties. The properties can be
 specified using the parameter
@@ -358,7 +360,7 @@ parameter within the application. The application will still have to
 still read the parameter in using the configuration API of the
 configuration object that is passed in populateDAG.
 
-##  Wildcards
+###  Wildcards
 
 Wildcards and regular expressions can be used in place of names to
 specify a group for applications, operators, ports or streams. For
@@ -376,7 +378,7 @@ also be used for operator name, stream name or application name. Regular
 expressions can also be used for names to specify attributes or
 properties for a specific set.
 
-## Adding configuration properties
+### Adding configuration properties
 
 It is common for applications to require configuration parameters to
 run.  For example, the address and port of the database, the location of
@@ -414,7 +416,7 @@ must be set at launch time, or it must be set by a pre-set configuration
 assigned with value some\_default\_value unless it is overridden at
 launch time.
 
-## Adding pre-set configurations
+### Adding pre-set configurations
 
 
 At build time, you can add pre-set configurations to the App Package by
@@ -423,7 +425,7 @@ project.  You can then specify which configuration to use at launch
 time.  The configuration XML is of the same format of the properties.xml
 file.
 
-## Application-specific properties file
+### Application-specific properties file
 
 You can also specify properties.xml per application in the application
 package.  Just create a file with the name properties-{appName}.xml and
@@ -436,7 +438,7 @@ Package
   properties-{appName}.xml: Properties that are specific when launching
 an application with the specified appName.
 
-## Properties source precedence
+### Properties source precedence
 
 If properties with the same key appear in multiple sources (e.g. from
 app package default configuration as META-INF/properties.xml, from app
@@ -455,7 +457,7 @@ etc), the precedence of sources, from highest to lowest, is as follows:
 7. dt-site.xml in local DT installation
 8. dt-site.xml stored in HDFS
 
-## Other meta-data
+### Other meta-data
 
 In a Apex App Package project, the pom.xml file contains a
 section that looks like:
@@ -475,7 +477,7 @@ lib/\*.jar, where lib is where all the dependency jars are kept within
 the Application Package.  One reason to change this field is when your
 Application Package needs the classpath in a specific order.
 
-## Logging configuration
+### Logging configuration
 
 Just like other Java projects, you can change the logging configuration
 by having your log4j.properties under src/main/resources.  For example,
@@ -494,7 +496,7 @@ Note that by default from project created from the maven archetype,
 there is already a log4j.properties file under src/test/resources and
 that file is only used for the unit test.
 
-# Zip Structure of Application Package
+## Zip Structure of Application Package
 
 
 Apache Apex Application Package files are zip files.  You can examine the content of any Application Package by using unzip -t on your Linux command line.
@@ -508,11 +510,11 @@ There are four top level directories in an Application Package:
 5. “resources” contains any other files
 
 
-# Examining and Launching Application Packages Through Apex CLI
+## Examining and Launching Application Packages Through Apex CLI
 
 If you are working with Application Packages in the local filesystem, you can use the Apex Command Line Interface (dtcli).  
 
-## Getting Application Package Meta Information
+### Getting Application Package Meta Information
 
 You can get the meta information about the Application Package using
 this Apex CLI command.
@@ -521,7 +523,7 @@ this Apex CLI command.
  dt> get-app-package-info <app-package-file>
 ```
 
-## Getting Available Operators In Application Package
+### Getting Available Operators In Application Package
 
 You can get the list of available operators in the Application Package
 using this command.
@@ -531,7 +533,7 @@ using this command.
  [parent-class]
 ```
 
-## Getting Properties of Operators in Application Package
+### Getting Properties of Operators in Application Package
 
 You can get the list of properties of any operator in the Application
 Package using this command.
@@ -539,7 +541,7 @@ Package using this command.
  dt> get-app-package-operator-properties <app-package-file> <operator-class>
 
 
-## Launching an Application Package
+### Launching an Application Package
 
 You can launch an application within an Application Package.
 ```
@@ -548,3 +550,146 @@ dt> launch [-D property-name=property-value, ...] [-conf config-name]
  [matching-app-name]
 ```
 Note that -conf expects a configuration file in the file system, while -apconf expects a configuration file within the app package.
+
+# Configuration Packages
+
+Sometimes just a configuration file is not enough for launching an application package. If a configuration requires
+additional files to be packaged, you can use an Apex Configuration Package.
+
+## Creating Configuration Packages
+
+Creating Configuration Packages is similar to creating Application Packages. You can create a configuration 
+package project using Maven by running the following command. Replace "com.example", "mydtconfig" and "1.0-SNAPSHOT" with the appropriate values:
+
+```
+$ mvn archetype:generate -DarchetypeGroupId=org.apache.apex \
+  -DarchetypeArtifactId=apex-conf-archetype -DarchetypeVersion=3.2.0-incubating \
+  -DgroupId=com.example -Dpackage=com.example.mydtconfig -DartifactId=mydtconfig \
+  -Dversion=1.0-SNAPSHOT
+```
+
+And create the configuration package file by running:
+
+```
+$ mvn package
+```
+
+The "mvn package" command creates the Config Package file in target
+directory as target/mydtconfig.apc. You will be able to use that
+Configuration Package file to launch an Apache Apex application.
+
+## Assembling your own configuration package
+
+Inside the project created by the archetype, these are the files that
+you should know about when assembling your own configuration package:
+
+    ./pom.xml
+    ./src/main/resources/classpath
+    ./src/main/resources/files
+    ./src/main/resources/META-INF/properties.xml
+    ./src/main/resources/META-INF/properties-{appname}.xml
+
+### pom.xml
+
+Example:
+
+```xml
+  <groupId>com.example</groupId>
+  <version>1.0.0</version>
+  <artifactId>mydtconf</artifactId>
+  <packaging>jar</packaging>
+  <!-- change these to the appropriate values -->
+  <name>My Apex Application Configuration</name>
+  <description>My Custom Application Configuration Description</description>
+  <properties>
+    <apex.apppackage.name>myapexapp</apex.apppackage.name>
+    <apex.apppackage.minversion>1.0.0</apex.apppackage.minversion>
+    <apex.apppackage.maxversion>1.9999.9999</apex.apppackage.maxversion>
+    <apex.appconf.classpath>classpath/*</apex.appconf.classpath>
+    <apex.appconf.files>files/*</apex.appconf.files>
+  </properties>
+
+```
+In pom.xml, you can change the following keys to your desired values
+
+* ```<groupId>```
+* ```<version>```
+* ```<artifactId>```
+* ```<name> ```
+* ```<description>```
+
+You can also change the values of
+
+* ```<apex.apppackage.name>```
+* ```<apex.apppackage.minversion>```
+* ```<apex.apppackage.maxversion>```
+
+to reflect what Application Packages can be used with this configuration package.  Apex will use this information to check whether a
+configuration package is compatible with the Application Package when you issue a launch command.
+
+### ./src/main/resources/classpath
+
+Place any file in this directory that you’d like to be copied to the
+compute machines when launching an application and included in the
+classpath of the application.  Example of such files are Java properties
+files and jar files.
+
+### ./src/main/resources/files
+
+Place any file in this directory that you’d like to be copied to the
+compute machines when launching an application but not included in the
+classpath of the application.
+
+### Properties XML file
+
+A properties xml file consists of a set of key-value pairs.  The set of
+key-value pairs specifies the configuration options the application
+should be launched with.
+
+Example:
+```xml
+<configuration>
+  <property>
+    <name>some-property-name</name>
+    <value>some-property-value</value>
+  </property>
+   ...
+</configuration>
+```
+Names of properties XML file:
+
+*  **properties.xml:** Properties that are global to the Configuration
+Package
+*  **properties-{appName}.xml:** Properties that are specific when launching
+an application with the specified appName within the Application
+Package.
+
+After you are done with the above, remember to do mvn package to
+generate a new configuration package, which will be located in the
+target directory in your project.
+
+### Zip structure of configuration package 
+Apex Application Configuration Package files are zip files.  You
+can examine the content of any Application Configuration Package by
+using unzip -t on your Linux command line.  The structure of the zip
+file is as follow:
+
+```
+META-INF
+  MANIFEST.MF
+  properties.xml
+  properties-{appname}.xml
+classpath
+  {classpath files}
+files
+  {files}
+```
+
+### Launching with CLI
+
+`-conf` option of the launch command in CLI supports specifying configuration package in the local filesystem.  Example:
+
+    dt\> launch DTApp-mydtapp-1.0.0.jar -conf DTConfig-mydtconfig-1.0.0.jar
+
+This command expects both the application package and the configuration package to be in the local file system.
+


[02/11] incubator-apex-core git commit: Migrating docs

Posted by th...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/docs/application_packages.md
----------------------------------------------------------------------
diff --git a/docs/application_packages.md b/docs/application_packages.md
new file mode 100644
index 0000000..521779a
--- /dev/null
+++ b/docs/application_packages.md
@@ -0,0 +1,669 @@
+Apache Apex Application Packages
+================================
+
+An Apache Apex Application Package is a zip file that contains all the
+necessary files to launch an application in Apache Apex. It is the
+standard way for assembling and sharing an Apache Apex application.
+
+# Requirements
+
+You will need have the following installed:
+
+1. Apache Maven 3.0 or later (for assembling the App Package)
+2. Apache Apex 3.0.0 or later (for launching the App Package in your cluster)
+
+# Creating Your First Apex App Package
+
+You can create an Apex Application Package using your Linux command
+line, or using your favorite IDE.
+
+## Using Command Line
+
+First, change to the directory where you put your projects, and create
+an Apex application project using Maven by running the following
+command.  Replace "com.example", "mydtapp" and "1.0-SNAPSHOT" with the
+appropriate values (make sure this is all on one line):
+
+    $ mvn archetype:generate \
+     -DarchetypeGroupId=org.apache.apex \
+     -DarchetypeArtifactId=apex-app-archetype -DarchetypeVersion=3.2.0-incubating \
+     -DgroupId=com.example -Dpackage=com.example.mydtapp -DartifactId=mydtapp \
+     -Dversion=1.0-SNAPSHOT
+
+This creates a Maven project named "mydtapp". Open it with your favorite
+IDE (e.g. NetBeans, Eclipse, IntelliJ IDEA). In the project, there is a
+sample DAG that generates a number of tuples with a random number and
+prints out "hello world" and the random number in the tuples.  The code
+that builds the DAG is in
+src/main/java/com/example/mydtapp/Application.java, and the code that
+runs the unit test for the DAG is in
+src/test/java/com/example/mydtapp/ApplicationTest.java. Try it out by
+running the following command:
+
+    $cd mydtapp; mvn package
+
+This builds the App Package runs the unit test of the DAG.  You should
+be getting test output similar to this:
+
+```
+ -------------------------------------------------------
+  TESTS
+ -------------------------------------------------------
+
+ Running com.example.mydtapp.ApplicationTest
+ hello world: 0.8015370953286478
+ hello world: 0.9785359225545481
+ hello world: 0.6322611586644047
+ hello world: 0.8460953663451775
+ hello world: 0.5719372906929072
+ hello world: 0.6361174312337172
+ hello world: 0.14873007534816318
+ hello world: 0.8866986277418261
+ hello world: 0.6346526809866057
+ hello world: 0.48587295703904465
+ hello world: 0.6436832429676687
+
+ ...
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 11.863
+ sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+```
+
+The "mvn package" command creates the App Package file in target
+directory as target/mydtapp-1.0-SNAPSHOT.apa. You will be able to use
+that App Package file to launch this sample application in your actual
+Apex installation.
+
+## Using IDE
+
+Alternatively, you can do the above steps all within your IDE.  For
+example, in NetBeans, select File -\> New Project.  Then choose “Maven”
+and “Project from Archetype” in the dialog box, as shown.
+
+![](images/AppPackage/ApplicationPackages.html-image00.png)
+
+Then fill the Group ID, Artifact ID, Version and Repository entries as shown below.
+
+![](images/AppPackage/ApplicationPackages.html-image02.png)
+
+Group ID: org.apache.apex
+Artifact ID: apex-app-archetype
+Version: 3.2.0-incubating (or any later version)
+
+Press Next and fill out the rest of the required information. For
+example:
+
+![](images/AppPackage/ApplicationPackages.html-image01.png)
+
+Click Finish, and now you have created your own Apache Apex App Package
+project, with a default unit test.  You can run the unit test, make code
+changes or make dependency changes within your IDE.  The procedure for
+other IDEs, like Eclipse or IntelliJ, is similar.
+
+# Writing Your Own App Package
+
+
+Please refer to the [Creating Apps](create.md) on the basics on how to write an Apache Apex application.  In your AppPackage project, you can add custom operators (refer to [Operator Development Guide](https://www.datatorrent.com/docs/guides/OperatorDeveloperGuide.html)), project dependencies, default and required configuration properties, pre-set configurations and other metadata.
+
+## Adding (and removing) project dependencies
+
+Under the project, you can add project dependencies in pom.xml, or do it
+through your IDE.  Here’s the section that describes the dependencies in
+the default pom.xml:
+```
+  <dependencies>
+    <!-- add your dependencies here -->
+    <dependency>
+      <groupId>org.apache.apex</groupId>
+      <artifactId>malhar-library</artifactId>
+      <version>${apex.version}</version>
+      <!--
+           If you know your application do not need the transitive dependencies that are pulled in by malhar-library,
+           Uncomment the following to reduce the size of your app package.
+      -->
+      <!--
+      <exclusions>
+        <exclusion>
+          <groupId>*</groupId>
+          <artifactId>*</artifactId>
+        </exclusion>
+      </exclusions>
+      -->
+    </dependency>
+    <dependency>
+      <groupId>org.apache.apex</groupId>
+      <artifactId>apex-engine</artifactId>
+      <version>${apex.version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.10</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+```
+
+By default, as shown above, the default dependencies include
+malhar-library in compile scope, dt-engine in provided scope, and junit
+in test scope.  Do not remove these three dependencies since they are
+necessary for any Apex application.  You can, however, exclude
+transitive dependencies from malhar-library to reduce the size of your
+App Package, provided that none of the operators in malhar-library that
+need the transitive dependencies will be used in your application.
+
+In the sample application, it is safe to remove the transitive
+dependencies from malhar-library, by uncommenting the "exclusions"
+section.  It will reduce the size of the sample App Package from 8MB to
+700KB.
+
+Note that if we exclude \*, in some versions of Maven, you may get
+warnings similar to the following:
+
+```
+
+ [WARNING] 'dependencies.dependency.exclusions.exclusion.groupId' for
+ org.apache.apex:malhar-library:jar with value '*' does not match a
+ valid id pattern.
+
+ [WARNING]
+ [WARNING] It is highly recommended to fix these problems because they
+ threaten the stability of your build.
+ [WARNING]
+ [WARNING] For this reason, future Maven versions might no longer support
+ building such malformed projects.
+ [WARNING]
+
+```
+This is a bug in early versions of Maven 3.  The dependency exclusion is
+still valid and it is safe to ignore these warnings.
+
+## Application Configuration
+
+A configuration file can be used to configure an application.  Different
+kinds of configuration parameters can be specified. They are application
+attributes, operator attributes and properties, port attributes, stream
+properties and application specific properties. They are all specified
+as name value pairs, in XML format, like the following.
+
+```
+<?xml version="1.0"?>
+<configuration>
+  <property>
+    <name>some_name_1</name>
+    <value>some_default_value</value>
+  </property>
+  <property>
+    <name>some_name_2</name>
+    <value>some_default_value</value>
+  </property>
+</configuration>
+```
+
+## Application attributes
+
+Application attributes are used to specify the platform behavior for the
+application. They can be specified using the parameter
+```dt.attr.<attribute>```. The prefix “dt” is a constant, “attr” is a
+constant denoting an attribute is being specified and ```<attribute>```
+specifies the name of the attribute. Below is an example snippet setting
+the streaming windows size of the application to be 1000 milliseconds.
+
+```
+  <property>
+     <name>dt.attr.STREAMING_WINDOW_SIZE_MILLIS</name>
+     <value>1000</value>
+  </property>
+```
+
+The name tag specifies the attribute and value tag specifies the
+attribute value. The name of the attribute is a JAVA constant name
+identifying the attribute. The constants are defined in
+com.datatorrent.api.Context.DAGContext and the different attributes can
+be specified in the format described above.
+
+## Operator attributes
+
+Operator attributes are used to specify the platform behavior for the
+operator. They can be specified using the parameter
+```dt.operator.<operator-name>.attr.<attribute>```. The prefix “dt” is a
+constant, “operator” is a constant denoting that an operator is being
+specified, ```<operator-name>``` denotes the name of the operator, “attr” is
+the constant denoting that an attribute is being specified and
+```<attribute>``` is the name of the attribute. The operator name is the
+same name that is specified when the operator is added to the DAG using
+the addOperator method. An example illustrating the specification is
+shown below. It specifies the number of streaming windows for one
+application window of an operator named “input” to be 10
+
+```
+<property>
+  <name>dt.operator.input.attr.APPLICATION_WINDOW_COUNT</name>
+  <value>10</value>
+</property>
+```
+
+The name tag specifies the attribute and value tag specifies the
+attribute value. The name of the attribute is a JAVA constant name
+identifying the attribute. The constants are defined in
+com.datatorrent.api.Context.OperatorContext and the different attributes
+can be specified in the format described above.
+
+## Operator properties
+
+Operators can be configured using operator specific properties. The
+properties can be specified using the parameter
+```dt.operator.<operator-name>.prop.<property-name>```. The difference
+between this and the operator attribute specification described above is
+that the keyword “prop” is used to denote that it is a property and
+```<property-name>``` specifies the property name.  An example illustrating
+this is specified below. It specifies the property “hostname” of the
+redis server for a “redis” output operator.
+
+```
+  <property>
+    <name>dt.operator.redis.prop.host</name>
+    <value>127.0.0.1</value>
+  </property>
+```
+
+The name tag specifies the property and the value specifies the property
+value. The property name is converted to a setter method which is called
+on the actual operator. The method name is composed by appending the
+word “set” and the property name with the first character of the name
+capitalized. In the above example the setter method would become
+setHost. The method is called using JAVA reflection and the property
+value is passed as an argument. In the above example the method setHost
+will be called on the “redis” operator with “127.0.0.1” as the argument.
+
+## Port attributes
+Port attributes are used to specify the platform behavior for input and
+output ports. They can be specified using the parameter ```dt.operator.<operator-name>.inputport.<port-name>.attr.<attribute>```
+for input port and ```dt.operator.<operator-name>.outputport.<port-name>.attr.<attribute>```
+for output port. The keyword “inputport” is used to denote an input port
+and “outputport” to denote an output port. The rest of the specification
+follows the conventions described in other specifications above. An
+example illustrating this is specified below. It specifies the queue
+capacity for an input port named “input” of an operator named “range” to
+be 4k.
+
+```
+<property>
+  <name>dt.operator.range.inputport.input.attr.QUEUE_CAPACITY</name>
+  <value>4000</value>
+</property>
+```
+
+The name tag specifies the attribute and value tag specifies the
+attribute value. The name of the attribute is a JAVA constant name
+identifying the attribute. The constants are defined in
+com.datatorrent.api.Context.PortContext and the different attributes can
+be specified in the format described above.
+
+The attributes for an output port can also be specified in a similar way
+as described above with a change that keyword “outputport” is used
+instead of “intputport”. A generic keyword “port” can be used to specify
+either an input or an output port. It is useful in the wildcard
+specification described below.
+
+## Stream properties
+
+Streams can be configured using stream properties. The properties can be
+specified using the parameter
+```dt.stream.<stream-name>.prop.<property-name>```  The constant “stream”
+specifies that it is a stream, ```<stream-name>``` specifies the name of the
+stream and ```<property-name>``` the name of the property. The name of the
+stream is the same name that is passed when the stream is added to the
+DAG using the addStream method. An example illustrating the
+specification is shown below. It sets the locality of the stream named
+“stream1” to container local indicating that the operators the stream is
+connecting be run in the same container.
+
+```
+  <property>
+    <name>dt.stream.stream1.prop.locality</name>
+    <value>CONTAINER_LOCAL</value>
+  </property>
+```
+
+The property name is converted into a set method on the stream in the
+same way as described in operator properties section above. In this case
+the method would be setLocality and it will be called in the stream
+“stream1” with the value as the argument.
+
+Along with the above system defined parameters, the applications can
+define their own specific parameters they can be specified in the
+configuration file. The only condition is that the names of these
+parameters don’t conflict with the system defined parameters or similar
+application parameters defined by other applications. To this end, it is
+recommended that the application parameters have the format
+```<full-application-class-name>.<param-name>.``` The
+full-application-class-name is the full JAVA class name of the
+application including the package path and param-name is the name of the
+parameter within the application. The application will still have to
+still read the parameter in using the configuration API of the
+configuration object that is passed in populateDAG.
+
+##  Wildcards
+
+Wildcards and regular expressions can be used in place of names to
+specify a group for applications, operators, ports or streams. For
+example, to specify an attribute for all ports of an operator it can be
+done as follows
+```
+<property>
+  <name>dt.operator.range.port.*.attr.QUEUE_CAPACITY</name>
+  <value>4000</value>
+</property>
+```
+
+The wildcard “\*” was used instead of the name of the port. Wildcard can
+also be used for operator name, stream name or application name. Regular
+expressions can also be used for names to specify attributes or
+properties for a specific set.
+
+## Adding configuration properties
+
+It is common for applications to require configuration parameters to
+run.  For example, the address and port of the database, the location of
+a file for ingestion, etc.  You can specify them in
+src/main/resources/META-INF/properties.xml under the App Package
+project. The properties.xml may look like:
+
+```
+<?xml version="1.0"?>
+<configuration>
+  <property>
+    <name>some_name_1</name>
+  </property>
+  <property>
+    <name>some_name_2</name>
+    <value>some_default_value</value>
+  </property>
+</configuration>
+```
+
+The name of an application-specific property takes the form of:
+
+```dt.operator.{opName}.prop.{propName} ```
+
+The first represents the property with name propName of operator opName.
+ Or you can set the application name at run time by setting this
+property:
+
+        dt.attr.APPLICATION_NAME
+
+There are also other properties that can be set.  For details on
+properties, refer to the [Operation and Installation Guide](https://www.datatorrent.com/docs/guides/OperationandInstallationGuide.html).
+
+In this example, property some_name_1 is a required property which
+must be set at launch time, or it must be set by a pre-set configuration
+(see next section).  Property some\_name\_2 is a property that is
+assigned with value some\_default\_value unless it is overridden at
+launch time.
+
+## Adding pre-set configurations
+
+
+At build time, you can add pre-set configurations to the App Package by
+adding configuration XML files under ```src/site/conf/<conf>.xml```in your
+project.  You can then specify which configuration to use at launch
+time.  The configuration XML is of the same format of the properties.xml
+file.
+
+## Application-specific properties file
+
+You can also specify properties.xml per application in the application
+package.  Just create a file with the name properties-{appName}.xml and
+it will be picked up when you launch the application with the specified
+name within the application package.  In short:
+
+  properties.xml: Properties that are global to the Configuration
+Package
+
+  properties-{appName}.xml: Properties that are specific when launching
+an application with the specified appName.
+
+## Properties source precedence
+
+If properties with the same key appear in multiple sources (e.g. from
+app package default configuration as META-INF/properties.xml, from app
+package configuration in the conf directory, from launch time defines,
+etc), the precedence of sources, from highest to lowest, is as follows:
+
+1. Launch time defines (using -D option in CLI, or the POST payload
+    with the Gateway REST API’s launch call)
+2. Launch time specified configuration file in file system (using -conf
+    option in CLI)
+3. Launch time specified package configuration (using -apconf option in
+    CLI or the conf={confname} with Gateway REST API’s launch call)
+4. Configuration from \$HOME/.dt/dt-site.xml
+5. Application defaults within the package as
+    META-INF/properties-{appname}.xml
+6. Package defaults as META-INF/properties.xml
+7. dt-site.xml in local DT installation
+8. dt-site.xml stored in HDFS
+
+## Other meta-data
+
+In a Apex App Package project, the pom.xml file contains a
+section that looks like:
+
+```
+<properties>
+  <apex.version>3.2.0-incubating</apex.version>
+  <apex.apppackage.classpath\>lib*.jar</apex.apppackage.classpath>
+</properties>
+```
+apex.version is the Apache Apex version that are to be used
+with this Application Package.
+
+apex.apppackage.classpath is the classpath that is used when
+launching the application in the Application Package.  The default is
+lib/\*.jar, where lib is where all the dependency jars are kept within
+the Application Package.  One reason to change this field is when your
+Application Package needs the classpath in a specific order.
+
+## Logging configuration
+
+Just like other Java projects, you can change the logging configuration
+by having your log4j.properties under src/main/resources.  For example,
+if you have the following in src/main/resources/log4j.properties:
+```
+ log4j.rootLogger=WARN,CONSOLE
+ log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+ log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+ log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} [%t] %-5p
+ %c{2} %M - %m%n
+```
+
+The root logger’s level is set to WARN and the output is set to the console (stdout).
+
+Note that by default from project created from the maven archetype,
+there is already a log4j.properties file under src/test/resources and
+that file is only used for the unit test.
+
+# Zip Structure of Application Package
+
+
+Apache Apex Application Package files are zip files.  You can examine the content of any Application Package by using unzip -t on your Linux command line.
+
+There are four top level directories in an Application Package:
+
+1. "app" contains the jar files of the DAG code and any custom operators.
+2. "lib" contains all dependency jars
+3. "conf" contains all the pre-set configuration XML files.
+4. "META-INF" contains the MANIFEST.MF file and the properties.xml file.
+5. “resources” contains other files that are to be served by the Gateway on behalf of the app package.
+
+
+# Managing Application Packages Through DT Gateway
+
+The DT Gateway provides storing and retrieving Application Packages to
+and from your distributed file system, e.g. HDFS.
+
+## Storing an Application Package
+
+You can store your Application Packages through DT Gateway using this
+REST call:
+
+```
+ POST /ws/v2/appPackages
+```
+
+The payload is the raw content of your Application Package.  For
+example, you can issue this request using curl on your Linux command
+line like this, assuming your DT Gateway is accepting requests at
+localhost:9090:
+
+```
+$ curl -XPOST -T <app-package-file> http://localhost:9090/ws/v2/appPackages
+```
+
+## Getting Meta Information on Application Packages
+
+
+You can get the meta information on Application Packages stored through
+DT Gateway using this call.  The information includes the logical plan
+of each application within the Application Package.
+
+```
+ GET /ws/v2/appPackages/{owner}/{pkgName}/{pkgVersion}
+```
+
+## Getting Available Operators In Application Package
+
+You can get the list of available operators in the Application Package
+using this call.
+
+```
+GET /ws/v2/appPackages/{owner}/{pkgName}/{pkgVersion}/operators?parent={parent}
+```
+
+The parent parameter is optional.  If given, parent should be the fully
+qualified class name.  It will only return operators that derive from
+that class or interface. For example, if parent is
+com.datatorrent.api.InputOperator, this call will only return input
+operators provided by the Application Package.
+
+## Getting Properties of Operators in Application Package
+
+You can get the list of properties of any operator in the Application
+Package using this call.
+
+```
+GET  /ws/v2/appPackages/{owner}/{pkgName}/{pkgVersion}/operators/{className}
+```
+
+## Getting List of Pre-Set Configurations in Application Package
+
+You can get a list of pre-set configurations within the Application
+Package using this call.
+
+```
+GET /ws/v2/appPackages/{owner}/{pkgName}/{packageVersion}/configs
+```
+
+You can also get the content of a specific pre-set configuration within
+the Application Package.
+
+```
+ GET /ws/v2/appPackages/{owner}/{pkgName}/{pkgVersion}/configs/{configName}
+```
+
+## Changing Pre-Set Configurations in Application Package
+
+You can create or replace pre-set configurations within the Application
+Package
+```
+ PUT   /ws/v2/appPackages/{owner}/{pkgName}/{pkgVersion}/configs/{configName}
+```
+The payload of this PUT call is the XML file that represents the pre-set configuration.  The Content-Type of the payload is "application/xml" and you can delete a pre-set configuration within the Application Package.
+```
+ DELETE /ws/v2/appPackages/{owner}/{pkgName}/{pkgVersion}/configs/{configName}
+```
+
+## Retrieving an Application Package
+
+You can download the Application Package file.  This Application Package
+is not necessarily the same file as the one that was originally uploaded
+since the pre-set configurations may have been modified.
+
+```
+ GET /ws/v2/appPackages/{owner}/{pkgName}/{pkgVersion}/download
+```
+
+## Launching an Application Package
+
+You can launch an application within an Application Package.
+```
+POST /ws/v2/appPackages/{owner}/{pkgName}/{pkgVersion}/applications/{appName}/launch?config={configName}
+```
+
+The config parameter is optional.  If given, it must be one of the
+pre-set configuration within the given Application Package.  The
+Content-Type of the payload of the POST request is "application/json"
+and should contain the properties to be launched with the application.
+ It is of the form:
+
+```
+ {"property-name":"property-value", ... }
+```
+
+Here is an example of launching an application through curl:
+
+```
+ $ curl -XPOST -d'{"dt.operator.console.prop.stringFormat":"xyz %s"}'
+ http://localhost:9090/ws/v2/appPackages/dtadmin/mydtapp/1.0-SNAPSHOT/app
+ lications/MyFirstApplication/launch
+```
+
+Please refer to the [Gateway API reference](https://www.google.com/url?q=https://www.datatorrent.com/docs/guides/DTGatewayAPISpecification.html&sa=D&usg=AFQjCNEWfN7-e7fd6MoWZjmJUE3GW7UwdQ) for the complete specification of the REST API.
+
+# Examining and Launching Application Packages Through Apex CLI
+
+If you are working with Application Packages in the local filesystem and
+do not want to deal with dtGateway, you can use the Apex Command Line Interface (dtcli).  Please refer to the [Gateway API](dtgateway_api.md)
+to see samples for these commands.
+
+## Getting Application Package Meta Information
+
+You can get the meta information about the Application Package using
+this Apex CLI command.
+
+```
+ dt> get-app-package-info <app-package-file>
+```
+
+## Getting Available Operators In Application Package
+
+You can get the list of available operators in the Application Package
+using this command.
+
+```
+ dt> get-app-package-operators <app-package-file> <package-prefix>
+ [parent-class]
+```
+
+## Getting Properties of Operators in Application Package
+
+You can get the list of properties of any operator in the Application
+Package using this command.
+
+ dt> get-app-package-operator-properties <app-package-file> <operator-class>
+
+
+## Launching an Application Package
+
+You can launch an application within an Application Package.
+```
+dt> launch [-D property-name=property-value, ...] [-conf config-name]
+ [-apconf config-file-within-app-package] <app-package-file>
+ [matching-app-name]
+```
+Note that -conf expects a configuration file in the file system, while -apconf expects a configuration file within the app package.

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/docs/autometrics.md
----------------------------------------------------------------------
diff --git a/docs/autometrics.md b/docs/autometrics.md
new file mode 100644
index 0000000..f6000e8
--- /dev/null
+++ b/docs/autometrics.md
@@ -0,0 +1,311 @@
+Apache Apex AutoMetrics
+=======================
+
+# Introduction
+Metrics collect various statistical information about a process which can be very useful for diagnosis. Auto Metrics in Apex can help monitor operators in a running application.  The goal of *AutoMetric* API is to enable operator developer to define relevant metrics for an operator in a simple way which the platform collects and reports automatically.
+
+# Specifying AutoMetrics in an Operator
+An *AutoMetric* can be any object. It can be of a primitive type - int, long, etc. or a complex one. A field or a `get` method in an operator can be annotated with `@AutoMetric` to specify that its value is a metric. After every application end window, the platform collects the values of these fields/methods in a map and sends it to application master.
+
+```java
+public class LineReceiver extends BaseOperator
+{
+ @AutoMetric
+ long length;
+
+ @AutoMetric
+ long count;
+
+ public final transient DefaultInputPort<String> input = new DefaultInputPort<String>()
+ {
+   @Override
+   public void process(String s)
+   {
+     length += s.length();
+     count++;
+   }
+ };
+
+ @Override
+ public void beginWindow(long windowId)
+ {
+   length = 0;
+   count = 0;
+ }
+}
+```
+
+There are 2 auto-metrics declared in the `LineReceiver`. At the end of each application window, the platform will send a map with 2 entries - `[(length, 100), (count, 10)]` to the application master.
+
+# Aggregating AutoMetrics across Partitions
+When an operator is partitioned, it is useful to aggregate the values of auto-metrics across all its partitions every window to get a logical view of these metrics. The application master performs these aggregations using metrics aggregators.
+
+The AutoMetric API helps to achieve this by providing an interface for writing aggregators- `AutoMetric.Aggregator`. Any implementation of `AutoMetric.Aggregator` can be set as an operator attribute - `METRICS_AGGREGATOR` for a particular operator which in turn is used for aggregating physical metrics.
+
+## Default aggregators
+[`MetricsAggregator`](https://github.com/apache/incubator-apex-core/blob/devel-3/common/src/main/java/com/datatorrent/common/metric/MetricsAggregator.java) is a simple implementation of `AutoMetric.Aggregator` that platform uses as a default for summing up primitive types - int, long, float and double.
+
+`MetricsAggregator` is just a collection of `SingleMetricAggregator`s. There are multiple implementations of `SingleMetricAggregator` that perform sum, min, max, avg which are present in Apex core and Apex malhar.
+
+For the `LineReceiver` operator, the application developer need not specify any aggregator. The platform will automatically inject an instance of `MetricsAggregator` that contains two `LongSumAggregator`s - one for `length` and one for `count`. This aggregator will report sum of length and sum of count across all the partitions of `LineReceiver`.
+
+
+## Building custom aggregators
+Platform cannot perform any meaningful aggregations for non-numeric metrics. In such cases, the operator or application developer can write custom aggregators. Let’s say, if the `LineReceiver` was modified to have a complex metric as shown below.
+
+```java
+public class AnotherLineReceiver extends BaseOperator
+{
+  @AutoMetric
+  final LineMetrics lineMetrics = new LineMetrics();
+
+  public final transient DefaultInputPort<String> input = new DefaultInputPort<String>()
+  {
+    @Override
+    public void process(String s)
+    {
+      lineMetrics.length += s.length();
+      lineMetrics.count++;
+    }
+  };
+
+  @Override
+  public void beginWindow(long windowId)
+  {
+    lineMetrics.length = 0;
+    lineMetrics.count = 0;
+  }
+
+  public static class LineMetrics implements Serializable
+  {
+    long length;
+    long count;
+
+    private static final long serialVersionUID = 201511041908L;
+  }
+}
+```
+
+Below is a custom aggregator that can calculate average line length across all partitions of `AnotherLineReceiver`.
+
+```java
+public class AvgLineLengthAggregator implements AutoMetric.Aggregator
+{
+
+  Map<String, Object> result = Maps.newHashMap();
+
+  @Override
+  public Map<String, Object> aggregate(long l, Collection<AutoMetric.PhysicalMetricsContext> collection)
+  {
+    long totalLength = 0;
+    long totalCount = 0;
+    for (AutoMetric.PhysicalMetricsContext pmc : collection) {
+      AnotherLineReceiver.LineMetrics lm = (AnotherLineReceiver.LineMetrics)pmc.getMetrics().get("lineMetrics");
+      totalLength += lm.length;
+      totalCount += lm.count;
+    }
+    result.put("avgLineLength", totalLength/totalCount);
+    return result;
+  }
+}
+```
+An instance of above aggregator can be specified as the `METRIC_AGGREGATOR` for `AnotherLineReceiver` while creating the DAG as shown below.
+
+```java
+  @Override
+  public void populateDAG(DAG dag, Configuration configuration)
+  {
+    ...
+    AnotherLineReceiver lineReceiver = dag.addOperator("LineReceiver", new AnotherLineReceiver());
+    dag.setAttribute(lineReceiver, Context.OperatorContext.METRICS_AGGREGATOR, new AvgLineLengthAggregator());
+    ...
+  }
+```
+
+# Retrieving AutoMetrics
+The Gateway REST API provides a way to retrieve the latest AutoMetrics for each logical operator.  For example:
+
+```
+GET /ws/v2/applications/{appid}/logicalPlan/operators/{opName}
+{
+    ...
+    "autoMetrics": {
+       "count": "71314",
+       "length": "27780706"
+    },
+    "className": "com.datatorrent.autometric.LineReceiver",
+    ...
+}
+```
+
+# System Metrics
+System metrics are standard operator metrics provided by the system.  Examples include:
+
+- processed tuples per second
+- emitted tuples per second
+- total tuples processed
+- total tuples emitted
+- latency
+- CPU percentage
+- failure count
+- checkpoint elapsed time
+
+The Gateway REST API provides a way to retrieve the latest values for all of the above for each of the logical operators in the application.
+
+```
+GET /ws/v2/applications/{appid}/logicalPlan/operators/{opName}
+{
+    ...
+    "cpuPercentageMA": "{cpuPercentageMA}",
+    "failureCount": "{failureCount}",
+    "latencyMA": "{latencyMA}",  
+    "totalTuplesEmitted": "{totalTuplesEmitted}",
+    "totalTuplesProcessed": "{totalTuplesProcessed}",
+    "tuplesEmittedPSMA": "{tuplesEmittedPSMA}",
+    "tuplesProcessedPSMA": "{tuplesProcessedPSMA}",
+    ...
+}
+```
+
+However, just like AutoMetrics, the Gateway only provides the latest metrics.  For historical metrics, we will need the help of App Data Tracker.
+
+# App Data Tracker
+As discussed above, STRAM aggregates the AutoMetrics from physical operators (partitions) to something that makes sense in one logical operator.  It pushes the aggregated AutoMetrics values using Websocket to the Gateway at every second along with system metrics for each operator.  Gateway relays the information to an application called App Data Tracker.  It is another Apex application that runs in the background and further aggregates the incoming values by time bucket and stores the values in HDHT.  It also allows the outside to retrieve the aggregated AutoMetrics and system metrics through websocket interface.
+
+![AppDataTracker](images/autometrics/adt.png)
+
+App Data Tracker is enabled by having these properties in dt-site.xml:
+
+```xml
+<property>
+  <name>dt.appDataTracker.enable</name>
+  <value>true</value>
+</property>
+<property>
+  <name>dt.appDataTracker.transport</name>
+  <value>builtin:AppDataTrackerFeed</value>
+</property>
+<property>
+  <name>dt.attr.METRICS_TRANSPORT</name>
+  <value>builtin:AppDataTrackerFeed</value>
+</property>
+```
+
+All the applications launched after the App Data Tracker is enabled will have metrics sent to it.
+
+**Note**: The App Data Tracker will be shown running in dtManage as a “system app”.  It will show up if the “show system apps” button is pressed.
+
+By default, the time buckets App Data Tracker aggregates upon are one minute, one hour and one day.  It can be overridden by changing the operator attribute `METRICS_DIMENSIONS_SCHEME`.
+
+Also by default, the app data tracker performs all these aggregations: SUM, MIN, MAX, AVG, COUNT, FIRST, LAST on all number metrics.  You can also override by changing the same operator attribute `METRICS_DIMENSIONS_SCHEME`, provided the custom aggregator is known to the App Data Tracker.  (See next section)
+
+# Custom Aggregator in App Data Tracker
+Custom aggregators allow you to do your own custom computation on statistics generated by any of your applications. In order to implement a Custom aggregator you have to do two things:
+
+1. Combining new inputs with the current aggregation
+2. Combining two aggregations together into one aggregation
+
+Let’s consider the case where we want to perform the following rolling average:
+
+Y_n = ½ * X_n + ½ * X_n-1 + ¼ * X_n-2 + ⅛ * X_n-3 +...
+
+This aggregation could be performed by the following Custom Aggregator:
+
+```java
+@Name("IIRAVG")
+public class AggregatorIIRAVG extends AbstractIncrementalAggregator
+{
+  ...
+
+  private void aggregateHelper(DimensionsEvent dest, DimensionsEvent src)
+  {
+    double[] destVals = dest.getAggregates().getFieldsDouble();
+    double[] srcVals = src.getAggregates().getFieldsDouble();
+
+    for (int index = 0; index < destLongs.length; index++) {
+      destVals[index] = .5 * destVals[index] + .5 * srcVals[index];
+    }
+  }
+
+  @Override
+  public void aggregate(Aggregate dest, InputEvent src)
+  {
+    //Aggregate a current aggregation with a new input
+    aggregateHelper(dest, src);
+  }
+
+  @Override
+  public void aggregate(Aggregate destAgg, Aggregate srcAgg)
+  {
+    //Combine two existing aggregations together
+    aggregateHelper(destAgg, srcAgg);
+  }
+}
+```
+
+## Discovery of Custom Aggregators
+AppDataTracker searches for custom aggregator jars under the following directories statically before launching:
+
+1. {dt\_installation\_dir}/plugin/aggregators
+2. {user\_home\_dir}/.dt/plugin/aggregators
+
+It uses reflection to find all the classes that extend from `IncrementalAggregator` and `OTFAggregator` in these jars and registers them with the name provided by `@Name` annotation (or class name when `@Name` is absent).
+
+# Using `METRICS_DIMENSIONS_SCHEME`
+
+Here is a sample code snippet on how you can make use of `METRICS_DIMENSIONS_SCHEME` to set your own time buckets and your own set of aggregators for certain `AutoMetric`s performed by the App Data Tracker in your application.
+
+```java
+  @Override
+  public void populateDAG(DAG dag, Configuration configuration)
+  {
+    ...
+    LineReceiver lineReceiver = dag.addOperator("LineReceiver", new LineReceiver());
+    ...
+    AutoMetric.DimensionsScheme dimensionsScheme = new AutoMetric.DimensionsScheme()
+    {
+      String[] timeBuckets = new String[] { "1s", "1m", "1h" };
+      String[] lengthAggregators = new String[] { "IIRAVG", "SUM" };
+      String[] countAggregators = new String[] { "SUM" };
+
+      /* Setting the aggregation time bucket to be one second, one minute and one hour */
+      @Override
+      public String[] getTimeBuckets()
+      {
+        return timeBuckets;
+      }
+
+      @Override
+      public String[] getDimensionAggregationsFor(String logicalMetricName)
+      {
+        if ("length".equals(logicalMetricName)) {
+          return lengthAggregators;
+        } else if ("count".equals(logicalMetricName)) {
+          return countAggregators;
+        } else {
+          return null; // use default
+        }
+      }
+    };
+
+    dag.setAttribute(lineReceiver, OperatorContext.METRICS_DIMENSIONS_SCHEME, dimensionsScheme);
+    ...
+  }
+```
+
+
+# Dashboards
+With App Data Tracker enabled, you can visualize the AutoMetrics and system metrics in the Dashboards within dtManage.   Refer back to the diagram in the App Data Tracker section, dtGateway relays queries and query results to and from the App Data Tracker.  In this way, dtManage sends queries and receives results from the App Data Tracker via dtGateway and uses the results to let the user visualize the data.
+
+Click on the visualize button in dtManage's application page.
+
+![AppDataTracker](images/autometrics/visualize.png)
+
+You will see the dashboard for the AutoMetrics and the system metrics.
+
+![AppDataTracker](images/autometrics/dashboard.png)
+
+The left widget shows the AutoMetrics of `line` and `count` for the LineReceiver operator.  The right widget shows the system metrics.
+
+The Dashboards have some simple builtin widgets to visualize the data.  Line charts and bar charts are some examples.
+Users will be able to implement their own widgets to visualize their data.

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/docs/dtcli.md
----------------------------------------------------------------------
diff --git a/docs/dtcli.md b/docs/dtcli.md
new file mode 100644
index 0000000..813a27f
--- /dev/null
+++ b/docs/dtcli.md
@@ -0,0 +1,273 @@
+Apache Apex Command Line Interface
+================================================================================
+
+dtCli, the Apache Apex command line interface, can be used to launch, monitor, and manage
+Apache Apex applications.  dtCli is a wrapper around the [REST API](dtgateway_api.md) provided by dtGatway, and
+provides a developer friendly way of interacting with Apache Apex platform. The CLI enables a much higher level of feature set by
+hiding deep details of REST API.  Another advantage of dtCli is to provide scope, by connecting and executing commands in a context
+of specific application.  dtCli enables easy integration with existing enterprise toolset for automated application monitoring
+and management.  Currently the following high level tasks are supported.
+
+-   Launch or kill applications
+-   View system metrics including load, throughput, latency, etc.
+-   Start or stop tuple recording
+-   Read operator, stream, port properties and attributes
+-   Write to operator properties
+-   Dynamically change the application logical plan
+-   Create custom macros
+
+
+## dtcli Commands
+
+dtCli can be launched by running following command on the same machine where dtGatway was installed
+
+    dtcli
+
+Help on all commands is available via “help” command in the CLI
+
+### Global Commands
+
+```
+GLOBAL COMMANDS EXCEPT WHEN CHANGING LOGICAL PLAN:
+
+alias alias-name command
+	Create a command alias
+
+begin-macro name
+	Begin Macro Definition ($1...$9 to access parameters and type 'end' to end the definition)
+
+connect app-id
+	Connect to an app
+
+dump-properties-file out-file jar-file class-name
+	Dump the properties file of an app class
+
+echo [arg ...]
+	Echo the arguments
+
+exit
+	Exit the CLI
+
+get-app-info app-id
+	Get the information of an app
+
+get-app-package-info app-package-file
+	Get info on the app package file
+
+get-app-package-operator-properties app-package-file operator-class
+	Get operator properties within the given app package
+
+get-app-package-operators [options] app-package-file [search-term]
+	Get operators within the given app package
+	Options:
+            -parent    Specify the parent class for the operators
+
+get-config-parameter [parameter-name]
+	Get the configuration parameter
+
+get-jar-operator-classes [options] jar-files-comma-separated [search-term]
+	List operators in a jar list
+	Options:
+            -parent    Specify the parent class for the operators
+
+get-jar-operator-properties jar-files-comma-separated operator-class-name
+	List properties in specified operator
+
+help [command]
+	Show help
+
+kill-app app-id [app-id ...]
+	Kill an app
+
+  launch [options] jar-file/json-file/properties-file/app-package-file [matching-app-name]
+  	Launch an app
+  	Options:
+            -apconf <app package configuration file>        Specify an application
+                                                            configuration file
+                                                            within the app
+                                                            package if launching
+                                                            an app package.
+            -archives <comma separated list of archives>    Specify comma
+                                                            separated archives
+                                                            to be unarchived on
+                                                            the compute machines.
+            -conf <configuration file>                      Specify an
+                                                            application
+                                                            configuration file.
+            -D <property=value>                             Use value for given
+                                                            property.
+            -exactMatch                                     Only consider
+                                                            applications with
+                                                            exact app name
+            -files <comma separated list of files>          Specify comma
+                                                            separated files to
+                                                            be copied on the
+                                                            compute machines.
+            -ignorepom                                      Do not run maven to
+                                                            find the dependency
+            -libjars <comma separated list of libjars>      Specify comma
+                                                            separated jar files
+                                                            or other resource
+                                                            files to include in
+                                                            the classpath.
+            -local                                          Run application in
+                                                            local mode.
+            -originalAppId <application id>                 Specify original
+                                                            application
+                                                            identifier for restart.
+            -queue <queue name>                             Specify the queue to
+                                                            launch the application
+
+list-application-attributes
+	Lists the application attributes
+list-apps [pattern]
+	List applications
+list-operator-attributes
+	Lists the operator attributes
+list-port-attributes
+	Lists the port attributes
+set-pager on/off
+	Set the pager program for output
+show-logical-plan [options] jar-file/app-package-file [class-name]
+	List apps in a jar or show logical plan of an app class
+	Options:
+            -exactMatch                                Only consider exact match
+                                                       for app name
+            -ignorepom                                 Do not run maven to find
+                                                       the dependency
+            -libjars <comma separated list of jars>    Specify comma separated
+                                                       jar/resource files to
+                                                       include in the classpath.
+shutdown-app app-id [app-id ...]
+	Shutdown an app
+source file
+	Execute the commands in a file
+```
+
+### Commands after connecting to an application
+
+```
+COMMANDS WHEN CONNECTED TO AN APP (via connect <appid>) EXCEPT WHEN CHANGING LOGICAL PLAN:
+
+begin-logical-plan-change
+	Begin Logical Plan Change
+dump-properties-file out-file [jar-file] [class-name]
+	Dump the properties file of an app class
+get-app-attributes [attribute-name]
+	Get attributes of the connected app
+get-app-info [app-id]
+	Get the information of an app
+get-operator-attributes operator-name [attribute-name]
+	Get attributes of an operator
+get-operator-properties operator-name [property-name]
+	Get properties of a logical operator
+get-physical-operator-properties [options] operator-id
+	Get properties of a physical operator
+	Options:
+            -propertyName <property name>    The name of the property whose
+                                             value needs to be retrieved
+            -waitTime <wait time>            How long to wait to get the result
+get-port-attributes operator-name port-name [attribute-name]
+	Get attributes of a port
+get-recording-info [operator-id] [start-time]
+	Get tuple recording info
+kill-app [app-id ...]
+	Kill an app
+kill-container container-id [container-id ...]
+	Kill a container
+list-containers
+	List containers
+list-operators [pattern]
+	List operators
+set-operator-property operator-name property-name property-value
+	Set a property of an operator
+set-physical-operator-property operator-id property-name property-value
+	Set a property of an operator
+show-logical-plan [options] [jar-file/app-package-file] [class-name]
+	Show logical plan of an app class
+	Options:
+            -exactMatch                                Only consider exact match
+                                                       for app name
+            -ignorepom                                 Do not run maven to find
+                                                       the dependency
+            -libjars <comma separated list of jars>    Specify comma separated
+                                                       jar/resource files to
+                                                       include in the classpath.
+show-physical-plan
+	Show physical plan
+shutdown-app [app-id ...]
+	Shutdown an app
+start-recording operator-id [port-name] [num-windows]
+	Start recording
+stop-recording operator-id [port-name]
+	Stop recording
+wait timeout
+	Wait for completion of current application
+```
+
+### Commands when changing the logical plan
+
+```
+COMMANDS WHEN CHANGING LOGICAL PLAN (via begin-logical-plan-change):
+
+abort
+	Abort the plan change
+add-stream-sink stream-name to-operator-name to-port-name
+	Add a sink to an existing stream
+create-operator operator-name class-name
+	Create an operator
+create-stream stream-name from-operator-name from-port-name to-operator-name to-port-name
+	Create a stream
+help [command]
+	Show help
+remove-operator operator-name
+	Remove an operator
+remove-stream stream-name
+	Remove a stream
+set-operator-attribute operator-name attr-name attr-value
+	Set an attribute of an operator
+set-operator-property operator-name property-name property-value
+	Set a property of an operator
+set-port-attribute operator-name port-name attr-name attr-value
+	Set an attribute of a port
+set-stream-attribute stream-name attr-name attr-value
+	Set an attribute of a stream
+show-queue
+	Show the queue of the plan change
+submit
+	Submit the plan change
+```
+
+
+
+## Examples
+
+An example of defining a custom macro.  The macro updates a running application by inserting a new operator.  It takes three parameters and executes a logical plan changes.
+
+```
+dt> begin-macro add-console-output
+macro> begin-logical-plan-change
+macro> create-operator $1 com.datatorrent.lib.io.ConsoleOutputOperator
+macro> create-stream stream_$1 $2 $3 $1 in
+macro> submit
+```
+
+
+Then execute the `add-console-output` macro like this
+
+```
+dt> add-console-output xyz opername portname
+```
+
+This macro then expands to run the following command
+
+```
+begin-logical-plan-change
+create-operator xyz com.datatorrent.lib.io.ConsoleOutputOperator
+create-stream stream_xyz opername portname xyz in
+submit
+```
+
+
+*Note*:  To perform runtime logical plan changes, like ability to add new operators,
+they must be part of the jar files that were deployed at application launch time.

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/docs/images/MalharOperatorOverview.png
----------------------------------------------------------------------
diff --git a/docs/images/MalharOperatorOverview.png b/docs/images/MalharOperatorOverview.png
new file mode 100644
index 0000000..40bee4a
Binary files /dev/null and b/docs/images/MalharOperatorOverview.png differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/docs/images/apex_logo.png
----------------------------------------------------------------------
diff --git a/docs/images/apex_logo.png b/docs/images/apex_logo.png
new file mode 100644
index 0000000..baa25ca
Binary files /dev/null and b/docs/images/apex_logo.png differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/docs/images/application_development/ApplicationDeveloperGuide.html-image00.png
----------------------------------------------------------------------
diff --git a/docs/images/application_development/ApplicationDeveloperGuide.html-image00.png b/docs/images/application_development/ApplicationDeveloperGuide.html-image00.png
new file mode 100644
index 0000000..87ebce4
Binary files /dev/null and b/docs/images/application_development/ApplicationDeveloperGuide.html-image00.png differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/docs/images/application_development/ApplicationDeveloperGuide.html-image01.png
----------------------------------------------------------------------
diff --git a/docs/images/application_development/ApplicationDeveloperGuide.html-image01.png b/docs/images/application_development/ApplicationDeveloperGuide.html-image01.png
new file mode 100644
index 0000000..4cdee33
Binary files /dev/null and b/docs/images/application_development/ApplicationDeveloperGuide.html-image01.png differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/docs/images/application_development/ApplicationDeveloperGuide.html-image02.png
----------------------------------------------------------------------
diff --git a/docs/images/application_development/ApplicationDeveloperGuide.html-image02.png b/docs/images/application_development/ApplicationDeveloperGuide.html-image02.png
new file mode 100644
index 0000000..5bf041c
Binary files /dev/null and b/docs/images/application_development/ApplicationDeveloperGuide.html-image02.png differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/docs/images/application_development/ApplicationDeveloperGuide.html-image03.png
----------------------------------------------------------------------
diff --git a/docs/images/application_development/ApplicationDeveloperGuide.html-image03.png b/docs/images/application_development/ApplicationDeveloperGuide.html-image03.png
new file mode 100644
index 0000000..e00bba5
Binary files /dev/null and b/docs/images/application_development/ApplicationDeveloperGuide.html-image03.png differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/docs/images/application_development/ApplicationDeveloperGuide.html-image04.png
----------------------------------------------------------------------
diff --git a/docs/images/application_development/ApplicationDeveloperGuide.html-image04.png b/docs/images/application_development/ApplicationDeveloperGuide.html-image04.png
new file mode 100644
index 0000000..8f62361
Binary files /dev/null and b/docs/images/application_development/ApplicationDeveloperGuide.html-image04.png differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/docs/images/application_development/ApplicationDeveloperGuide.html-image05.png
----------------------------------------------------------------------
diff --git a/docs/images/application_development/ApplicationDeveloperGuide.html-image05.png b/docs/images/application_development/ApplicationDeveloperGuide.html-image05.png
new file mode 100644
index 0000000..f9ea8d9
Binary files /dev/null and b/docs/images/application_development/ApplicationDeveloperGuide.html-image05.png differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/docs/images/application_development/ApplicationDeveloperGuide.html-image06.png
----------------------------------------------------------------------
diff --git a/docs/images/application_development/ApplicationDeveloperGuide.html-image06.png b/docs/images/application_development/ApplicationDeveloperGuide.html-image06.png
new file mode 100644
index 0000000..346690c
Binary files /dev/null and b/docs/images/application_development/ApplicationDeveloperGuide.html-image06.png differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/docs/images/application_development/ApplicationDeveloperGuide.html-image07.png
----------------------------------------------------------------------
diff --git a/docs/images/application_development/ApplicationDeveloperGuide.html-image07.png b/docs/images/application_development/ApplicationDeveloperGuide.html-image07.png
new file mode 100644
index 0000000..e57a8eb
Binary files /dev/null and b/docs/images/application_development/ApplicationDeveloperGuide.html-image07.png differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/docs/images/application_development/ApplicationDeveloperGuide.html-image08.png
----------------------------------------------------------------------
diff --git a/docs/images/application_development/ApplicationDeveloperGuide.html-image08.png b/docs/images/application_development/ApplicationDeveloperGuide.html-image08.png
new file mode 100644
index 0000000..a363f94
Binary files /dev/null and b/docs/images/application_development/ApplicationDeveloperGuide.html-image08.png differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/docs/images/application_development/ApplicationDeveloperGuide.html-image09.png
----------------------------------------------------------------------
diff --git a/docs/images/application_development/ApplicationDeveloperGuide.html-image09.png b/docs/images/application_development/ApplicationDeveloperGuide.html-image09.png
new file mode 100644
index 0000000..8a0252b
Binary files /dev/null and b/docs/images/application_development/ApplicationDeveloperGuide.html-image09.png differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/docs/images/operator/image00.png
----------------------------------------------------------------------
diff --git a/docs/images/operator/image00.png b/docs/images/operator/image00.png
new file mode 100644
index 0000000..14588aa
Binary files /dev/null and b/docs/images/operator/image00.png differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/docs/images/operator/image01.png
----------------------------------------------------------------------
diff --git a/docs/images/operator/image01.png b/docs/images/operator/image01.png
new file mode 100644
index 0000000..626c6b5
Binary files /dev/null and b/docs/images/operator/image01.png differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/docs/images/operator/image02.png
----------------------------------------------------------------------
diff --git a/docs/images/operator/image02.png b/docs/images/operator/image02.png
new file mode 100644
index 0000000..2be9433
Binary files /dev/null and b/docs/images/operator/image02.png differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/docs/images/operator/image03.png
----------------------------------------------------------------------
diff --git a/docs/images/operator/image03.png b/docs/images/operator/image03.png
new file mode 100644
index 0000000..67802d8
Binary files /dev/null and b/docs/images/operator/image03.png differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/docs/images/operator/image04.png
----------------------------------------------------------------------
diff --git a/docs/images/operator/image04.png b/docs/images/operator/image04.png
new file mode 100644
index 0000000..58d99d9
Binary files /dev/null and b/docs/images/operator/image04.png differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/docs/images/operator/image05.png
----------------------------------------------------------------------
diff --git a/docs/images/operator/image05.png b/docs/images/operator/image05.png
new file mode 100644
index 0000000..9ac6f21
Binary files /dev/null and b/docs/images/operator/image05.png differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/docs/operator_development.md
----------------------------------------------------------------------
diff --git a/docs/operator_development.md b/docs/operator_development.md
new file mode 100644
index 0000000..f502725
--- /dev/null
+++ b/docs/operator_development.md
@@ -0,0 +1,449 @@
+Operator Development Guide
+==========================
+
+Operators are basic building blocks of an application built to run on
+Apache Apex platform. An application may consist of one or more
+operators each of which define some logical operation to be done on the
+tuples arriving at the operator. These operators are connected together
+using streams forming a Directed Acyclic Graph (DAG). In other words, a streaming
+application is represented by a DAG that consists of operations (called operators) and
+data flow (called streams).
+
+In this document we will discuss details on how an operator works and
+its internals. This document is intended to serve the following purposes
+
+1.  **[Apache Apex Operators](#apex_operators)** - Introduction to operator terminology and concepts.
+2.  **[Writing Custom Operators](#writing_custom_operators)** - Designing, coding and testing new operators from scratch.  Includes code examples.
+3.  **[Operator Reference](#operator_reference)** - Details of operator internals, lifecycle, and best practices and optimizations.
+
+* * * * *
+
+Apache Apex Operators <a name="apex_operators"></a>
+==========================================
+
+Operators - “What” in a nutshell
+--------------------------------
+
+Operators are independent units of logical operations which can
+contribute in executing the business logic of a use case. For example,
+in an ETL workflow, a filtering operation can be represented by a single
+operator. This filtering operator will be responsible for doing just one
+task in the ETL pipeline, i.e. filter incoming tuples. Operators do not
+impose any restrictions on what can or cannot be done as part of a
+operator. An operator may as well contain the entire business logic.
+However, it is recommended, that the operators are light weight
+independent tasks, in
+order to take advantage of the distributed framework that Apache Apex
+provides. The structure of a streaming application shares resemblance
+with the way CPU pipelining works. CPU pipelining breaks down the
+computation engine into different stages viz. instruction fetch,
+instruction decode, etc. so that each of them can perform their task on
+different instructions
+parallely. Similarly,
+Apache Apex APIs allow the user to break down their tasks into different
+stages so that all of the tasks can be executed on different tuples
+parallely.
+
+![](images/operator/image05.png)
+
+Operators - “How” in a nutshell
+-------------------------------
+
+An Apache Apex application runs as a YARN application. Hence, each of
+the operators that the application DAG contains, runs in one of the
+containers provisioned by YARN. Further, Apache Apex exposes APIs to
+allow the user to request bundling multiple operators in a single node,
+a single container or even a single thread. We shall look at these calls
+in the reference sections [cite reference sections]. For now, consider
+an operator as some piece of code that runs on some machine of a YARN
+cluster.
+
+Types of Operators
+------------------
+
+An operator works on one tuple at a time. These tuples may be supplied
+by other operators in the application or by external sources,
+such as a database or a message bus. Similarly, after the tuples are
+processed, these may be passed on to other operators, or stored into an external system. 
+Therea are 3 type of operators based on function: 
+
+1.  **Input Adapter** - This is one of the starting points in
+    the application DAG and is responsible for getting tuples from an
+    external system. At the same time, such data may also be generated
+    by the operator itself, without interacting with the outside
+    world. These input tuples will form the initial universe of
+    data that the application works on.
+2.  **Generic Operator** - This type of operator accepts input tuples from
+    the previous operators and passes them on to the following operators
+    in the DAG.
+3.  **Output Adapter** - This is one of the ending points in the application
+    DAG and is responsible for writing the data out to some external
+    system.
+
+Note: There can be multiple operators of all types in an application
+DAG.
+
+Operators Position in a DAG
+-----------------------------------
+
+We may refer to operators depending on their position with respect to
+one another. For any operator opr (see image below), there are two types of operators.
+
+1.  **Upstream operators** - These are the operators from which there is a
+    directed path to opr in the application DAG.
+2.  **Downstream operators** - These are the operators to which there is a
+    directed path from opr in the application DAG.
+
+Note that there are no cycles formed in the application DAG.
+
+![](images/operator/image00.png)
+
+Ports
+-----
+
+Operators in a DAG are connected together via directed flows
+called streams. Each stream has end-points located on the operators
+called ports. Therea are 2 types of ports.
+
+1.  **Input Port** - This is a port through which an operator accepts input
+    tuples from an upstream operator.
+2.  **Output port** - This is a port through which an operator passes on the
+    processed data to downstream operators.
+
+Looking at the number of input ports, an Input Adapter is an operator
+with no input ports, a Generic operator has both input and output ports,
+while an Output Adapter has no output ports. At the same time, note that
+an operator may act as an Input Adapter while at the same time have an
+input port. In such cases, the operator is getting data from two
+different sources, viz. the input stream from the input port and an
+external source.
+
+![](images/operator/image02.png)
+
+* * * * *
+
+How Operator Works
+----------------------
+
+An operator passes through various stages during its lifetime. Each
+stage is an API call that the Streaming Application Master makes for an
+operator.  The following figure illustrates the stages through which an
+operator passes.
+
+![](images/operator/image01.png)
+
+-   The _setup()_ call initializes the operator and prepares itself to
+    start processing tuples.
+-   The _beginWindow()_ call marks the beginning of an application window
+    and allows for any processing to be done before a window starts.
+-   The _process()_ call belongs to the _InputPort_ and gets triggered when
+    any tuple arrives at the Input port of the operator. This call is
+    specific only to Generic and Output adapters, since Input Adapters
+    do not have an input port. This is made for all the tuples at the
+    input port until the end window marker tuple is received on the
+    input port.
+-   The _emitTuples()_ is the counterpart of _process()_ call for Input
+    Adapters.
+    This call is used by Input adapters to emit any tuples that are
+    fetched from the external systems, or generated by the operator.
+    This method is called continuously until the pre-configured window
+    time is elapsed, at which the end window marker tuple is sent out on
+    the output port.
+-   The _endWindow()_ call marks the end of the window and allows for any
+    processing to be done after the window ends.
+-   The _teardown()_ call is used for gracefully shutting down the
+    operator and releasing any resources held by the operator.
+
+Developing Custom Operators <a name="writing_custom_operators"></a>
+====================================
+
+About this tutorial
+-------------------
+
+This tutorial will guide the user towards developing a operator from
+scratch. It includes all aspects of writing an operator including
+design, code and unit testing.
+
+Introduction
+------------
+
+In this tutorial, we will design and write, from scratch, an operator
+called Word Count. This operator will accept tuples of type String,
+count the number of occurrences for each word appearing in the tuple and
+send out the updated counts for all the words encountered in the tuple.
+Further, the operator will also accept a file path on HDFS which will
+contain the stop-words which need to be ignored when counting
+occurrences.
+
+Design
+------
+
+Design of the operator must be finalized before starting to write an
+operator. Many aspects including the functionality, the data sources,
+the types involved etc. need to be first finalized before writing the
+operator. Let us dive into each of these while considering the Word
+Count operator.
+
+### Functionality
+
+We can define the scope of operator functionality using the following
+tasks:
+
+1.  Parse the input tuple to identify the words in the tuple
+2.  Identify the stop-words in the tuple by looking up the stop-word
+    file as configured
+3.  For each non-stop-word in the tuple, count the occurrences in that
+    tuple and add it to a global counts
+
+Let’s consider an example. Suppose we have the following tuples flow
+into the Word Count operator.
+
+1.  _Humpty dumpty sat on a wall_
+2.  _Humpty dumpty had a great fall_
+
+Initially counts for all words is 0. Once the first tuple is processed,
+the counts that must be emitted are:
+
+``` java
+humpty - 1
+dumpty - 1
+sat - 1
+wall - 1
+```
+
+Note that we are ignoring the stop-words, “on” and “a” in this case.
+Also note that as a rule, we’ll ignore the case of the words when
+counting occurrences.
+
+Similarly, after the second tuple is processed, the counts that must be
+emitted are:
+
+``` java
+humpty - 2
+dumpty - 2
+great - 1
+fall - 1
+```
+
+Again, we ignore the words _“had”_ and _“a”_ since these are stop-words.
+
+Note that the most recent count for any word is correct count for that
+word. In other words, any new output for a word, invalidated all the
+previous counts for that word.
+
+### Inputs
+
+As seen from the example above, the following inputs are expected for
+the operator:
+
+1.  Input stream whose tuple type is String
+2.  Input HDFS file path, pointing to a file containing stop-words
+
+Only one input port is needed. The stop-word file will be small enough
+to be read completely in a single read. In addition this will be a one
+time activity for the lifetime of the operator. This does not need a
+separate input port.
+
+![](images/operator/image03.png)
+
+### Outputs
+
+We can define the output for this operator in multiple ways.
+
+1.  The operator may send out the set of counts for which the counts
+    have changed after processing each tuple.
+2.  Some applications might not need an update after every tuple, but
+    only after a certain time duration.
+
+Let us try and implement both these options depending on the
+configuration. Let us define a boolean configuration parameter
+_“sendPerTuple”_. The value of this parameter will indicate whether the
+updated counts for words need to be emitted after processing each
+tuple (true) or after a certain time duration (false).
+
+The type of information the operator will be sending out on the output
+port is the same for all the cases. This will be a _< key, value >_ pair,
+where the key is the word while, the value is the latest count for that
+word. This means we just need one output port on which this information
+will go out.
+
+![](images/operator/image04.png)
+
+Configuration
+-------------
+
+We have the following configuration parameters:
+
+1.  _stopWordFilePath_ - This parameter will store the path to the stop
+    word file on HDFS as configured by the user.
+2.  _sendPerTuple_ - This parameter decides whether we send out the
+    updated counts after processing each tuple or at the end of a
+    window. When set to true, the operator will send out the updated
+    counts after each tuple, else it will send at the end of
+    each window.
+
+Code
+----
+
+The source code for the tutorial can be found here:
+
+[https://github.com/DataTorrent/examples/tree/master/tutorials/operatorTutorial](https://www.google.com/url?q=https://github.com/DataTorrent/examples/tree/master/tutorials/operatorTutorial&sa=D&usg=AFQjCNHAAgSpNprHJVvy9GSjdlD1uwU7jw)
+
+
+Operator Reference <a name="operator_reference"></a>
+====================================
+
+
+### The Operator Class
+
+The operator will exist physically as a class which implements the
+Operator interface. This interface will require implementations for the
+following method calls:
+
+-  setup(OperatorContext context)
+-  beginWindow(long windowId)
+-  endWindow()
+-  tearDown()
+
+In order to simplify the creation of an operator, Apache Apex
+library also provides a base class “BaseOperator” which has empty
+implementations for these methods. Please refer to the [Apex Operators](#apex_operators) section and the
+[Reference](#operator_reference) section for details on these.
+
+We extend the class “BaseOperator” to create our own operator
+“WordCountOperator”.
+
+``` java
+public class WordCountOperator extends BaseOperator
+{
+}
+```
+
+### Class (Operator) properties
+
+We define the following class variables:
+
+-   _sendPerTuple_ - Configures the output frequency from the operator
+``` java
+private boolean sendPerTuple = true; // default
+```
+-   _stopWordFilePath_ - Stores the path to the stop words file on HDFS
+``` java
+private String stopWordFilePath; // no default
+```
+-   _stopWords_ - Stores the stop words read from the configured file
+``` java
+private transient String[] stopWords;
+```
+-   _globalCounts_ - A Map which stores the counts of all the words
+    encountered so far. Note that this variable is non transient, which
+    means that this variable is saved as part of the checkpoint and can be recovered in event of a crash.
+``` java
+private Map<String, Long> globalCounts;
+```
+-   _updatedCounts_ - A Map which stores the counts for only the most
+    recent tuple(s). sendPerTuple configuration determines whether to store the most recent or the recent
+    window worth of tuples.
+``` java
+private transient Map<String, Long> updatedCounts;
+```
+-   _input_ - The input port for the operator. The type of this input port
+    is String which means it will only accept tuples of type String. The
+    definition of an input port requires implementation of a method
+    called process(String tuple), which should have the processing logic
+    for the input tuple which  arrives at this input port. We delegate
+    this task to another method called processTuple(String tuple). This
+    helps in keeping the operator classes extensible by overriding the
+    processing logic for the input tuples.
+``` java
+public transient DefaultInputPort<String> input = new    
+DefaultInputPort<String>()
+{
+    @Override
+    public void process(String tuple)
+    {
+        processTuple(tuple);
+    }
+};
+```
+-   output - The output port for the operator. The type of this port is
+    Entry < String, Long >, which means the operator will emit < word,
+    count > pairs for the updated counts.
+``` java
+public transient DefaultOutputPort <Entry<String, Long>> output = new
+DefaultOutputPort<Entry<String,Long>>();
+```
+
+### The Constructor
+
+The constructor is the place where we initialize the non-transient data
+structures, since
+constructor is called just once per activation of an operator. With regards to Word Count operator, we initialize the globalCounts variable in the constructor.
+``` java
+globalCounts = Maps.newHashMap();
+```
+### Setup call
+
+The setup method is called only once during an operator lifetime and its purpose is to allow 
+the operator to set itself up for processing incoming streams. Transient objects in the operator are
+not serialized and checkpointed. Hence, it is essential that such objects initialized in the setup call. 
+In case of operator failure, the operator will be redeployed (most likely on a different container). The setup method called by the Apache Apex engine allows the operator to prepare for execution in the new container.
+
+The following tasks are executed as part of the setup call:
+
+1.  Read the stop-word list from HDFS and store it in the
+    stopWords array
+2.  Initialize updatedCounts variable. This will store the updated
+    counts for words in most recent tuples processed by the operator.
+    As a transient variable, the value will be lost when operator fails.
+
+### Begin Window call
+
+The begin window call signals the start of an application window. With 
+regards to Word Count Operator, we are expecting updated counts for the most recent window of
+data if the sendPerTuple is set to false. Hence, we clear the updatedCounts variable in the begin window
+call and start accumulating the counts till the end window call.
+
+### Process Tuple call
+
+The processTuple method is called by the process method of the input
+port, input. This method defines the processing logic for the current
+tuple that is received at the input port. As part of this method, we
+identify the words in the current tuple and update the globalCounts and
+the updatedCounts variables. In addition, if the sendPerTuple variable
+is set to true, we also emit the words and corresponding counts in
+updatedCounts to the output port. Note that in this case (sendPerTuple =
+true), we clear the updatedCounts variable in every call to
+processTuple.
+
+### End Window call
+
+This call signals the end of an application window. With regards to Word
+Count Operator, we emit the updatedCounts to the output port if the
+sendPerTuple flag is set to false.
+
+### Teardown call
+
+This method allows the operator to gracefully shut down itself after
+releasing the resources that it has acquired. With regards to our operator,
+we call the shutDown method which shuts down the operator along with any
+downstream operators.
+
+Testing your Operator
+---------------------
+
+As part of testing our operator, we test the following two facets:
+
+1.  Test output of the operator after processing a single tuple
+2.  Test output of the operator after processing of a window of tuples
+
+The unit tests for the WordCount operator are available in the class
+WordCountOperatorTest.java. We simulate the behavior of the engine by
+using the test utilities provided by Apache Apex libraries. We simulate
+the setup, beginWindow, process method of the input port and
+endWindow calls and compare the output received at the simulated output
+ports.
+
+1. Invoke constructor; non-transients initialized.
+2. Copy state from checkpoint -- initialized values from step 1 are
+replaced.

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/dtcli.md
----------------------------------------------------------------------
diff --git a/dtcli.md b/dtcli.md
deleted file mode 100644
index 813a27f..0000000
--- a/dtcli.md
+++ /dev/null
@@ -1,273 +0,0 @@
-Apache Apex Command Line Interface
-================================================================================
-
-dtCli, the Apache Apex command line interface, can be used to launch, monitor, and manage
-Apache Apex applications.  dtCli is a wrapper around the [REST API](dtgateway_api.md) provided by dtGatway, and
-provides a developer friendly way of interacting with Apache Apex platform. The CLI enables a much higher level of feature set by
-hiding deep details of REST API.  Another advantage of dtCli is to provide scope, by connecting and executing commands in a context
-of specific application.  dtCli enables easy integration with existing enterprise toolset for automated application monitoring
-and management.  Currently the following high level tasks are supported.
-
--   Launch or kill applications
--   View system metrics including load, throughput, latency, etc.
--   Start or stop tuple recording
--   Read operator, stream, port properties and attributes
--   Write to operator properties
--   Dynamically change the application logical plan
--   Create custom macros
-
-
-## dtcli Commands
-
-dtCli can be launched by running following command on the same machine where dtGatway was installed
-
-    dtcli
-
-Help on all commands is available via “help” command in the CLI
-
-### Global Commands
-
-```
-GLOBAL COMMANDS EXCEPT WHEN CHANGING LOGICAL PLAN:
-
-alias alias-name command
-	Create a command alias
-
-begin-macro name
-	Begin Macro Definition ($1...$9 to access parameters and type 'end' to end the definition)
-
-connect app-id
-	Connect to an app
-
-dump-properties-file out-file jar-file class-name
-	Dump the properties file of an app class
-
-echo [arg ...]
-	Echo the arguments
-
-exit
-	Exit the CLI
-
-get-app-info app-id
-	Get the information of an app
-
-get-app-package-info app-package-file
-	Get info on the app package file
-
-get-app-package-operator-properties app-package-file operator-class
-	Get operator properties within the given app package
-
-get-app-package-operators [options] app-package-file [search-term]
-	Get operators within the given app package
-	Options:
-            -parent    Specify the parent class for the operators
-
-get-config-parameter [parameter-name]
-	Get the configuration parameter
-
-get-jar-operator-classes [options] jar-files-comma-separated [search-term]
-	List operators in a jar list
-	Options:
-            -parent    Specify the parent class for the operators
-
-get-jar-operator-properties jar-files-comma-separated operator-class-name
-	List properties in specified operator
-
-help [command]
-	Show help
-
-kill-app app-id [app-id ...]
-	Kill an app
-
-  launch [options] jar-file/json-file/properties-file/app-package-file [matching-app-name]
-  	Launch an app
-  	Options:
-            -apconf <app package configuration file>        Specify an application
-                                                            configuration file
-                                                            within the app
-                                                            package if launching
-                                                            an app package.
-            -archives <comma separated list of archives>    Specify comma
-                                                            separated archives
-                                                            to be unarchived on
-                                                            the compute machines.
-            -conf <configuration file>                      Specify an
-                                                            application
-                                                            configuration file.
-            -D <property=value>                             Use value for given
-                                                            property.
-            -exactMatch                                     Only consider
-                                                            applications with
-                                                            exact app name
-            -files <comma separated list of files>          Specify comma
-                                                            separated files to
-                                                            be copied on the
-                                                            compute machines.
-            -ignorepom                                      Do not run maven to
-                                                            find the dependency
-            -libjars <comma separated list of libjars>      Specify comma
-                                                            separated jar files
-                                                            or other resource
-                                                            files to include in
-                                                            the classpath.
-            -local                                          Run application in
-                                                            local mode.
-            -originalAppId <application id>                 Specify original
-                                                            application
-                                                            identifier for restart.
-            -queue <queue name>                             Specify the queue to
-                                                            launch the application
-
-list-application-attributes
-	Lists the application attributes
-list-apps [pattern]
-	List applications
-list-operator-attributes
-	Lists the operator attributes
-list-port-attributes
-	Lists the port attributes
-set-pager on/off
-	Set the pager program for output
-show-logical-plan [options] jar-file/app-package-file [class-name]
-	List apps in a jar or show logical plan of an app class
-	Options:
-            -exactMatch                                Only consider exact match
-                                                       for app name
-            -ignorepom                                 Do not run maven to find
-                                                       the dependency
-            -libjars <comma separated list of jars>    Specify comma separated
-                                                       jar/resource files to
-                                                       include in the classpath.
-shutdown-app app-id [app-id ...]
-	Shutdown an app
-source file
-	Execute the commands in a file
-```
-
-### Commands after connecting to an application
-
-```
-COMMANDS WHEN CONNECTED TO AN APP (via connect <appid>) EXCEPT WHEN CHANGING LOGICAL PLAN:
-
-begin-logical-plan-change
-	Begin Logical Plan Change
-dump-properties-file out-file [jar-file] [class-name]
-	Dump the properties file of an app class
-get-app-attributes [attribute-name]
-	Get attributes of the connected app
-get-app-info [app-id]
-	Get the information of an app
-get-operator-attributes operator-name [attribute-name]
-	Get attributes of an operator
-get-operator-properties operator-name [property-name]
-	Get properties of a logical operator
-get-physical-operator-properties [options] operator-id
-	Get properties of a physical operator
-	Options:
-            -propertyName <property name>    The name of the property whose
-                                             value needs to be retrieved
-            -waitTime <wait time>            How long to wait to get the result
-get-port-attributes operator-name port-name [attribute-name]
-	Get attributes of a port
-get-recording-info [operator-id] [start-time]
-	Get tuple recording info
-kill-app [app-id ...]
-	Kill an app
-kill-container container-id [container-id ...]
-	Kill a container
-list-containers
-	List containers
-list-operators [pattern]
-	List operators
-set-operator-property operator-name property-name property-value
-	Set a property of an operator
-set-physical-operator-property operator-id property-name property-value
-	Set a property of an operator
-show-logical-plan [options] [jar-file/app-package-file] [class-name]
-	Show logical plan of an app class
-	Options:
-            -exactMatch                                Only consider exact match
-                                                       for app name
-            -ignorepom                                 Do not run maven to find
-                                                       the dependency
-            -libjars <comma separated list of jars>    Specify comma separated
-                                                       jar/resource files to
-                                                       include in the classpath.
-show-physical-plan
-	Show physical plan
-shutdown-app [app-id ...]
-	Shutdown an app
-start-recording operator-id [port-name] [num-windows]
-	Start recording
-stop-recording operator-id [port-name]
-	Stop recording
-wait timeout
-	Wait for completion of current application
-```
-
-### Commands when changing the logical plan
-
-```
-COMMANDS WHEN CHANGING LOGICAL PLAN (via begin-logical-plan-change):
-
-abort
-	Abort the plan change
-add-stream-sink stream-name to-operator-name to-port-name
-	Add a sink to an existing stream
-create-operator operator-name class-name
-	Create an operator
-create-stream stream-name from-operator-name from-port-name to-operator-name to-port-name
-	Create a stream
-help [command]
-	Show help
-remove-operator operator-name
-	Remove an operator
-remove-stream stream-name
-	Remove a stream
-set-operator-attribute operator-name attr-name attr-value
-	Set an attribute of an operator
-set-operator-property operator-name property-name property-value
-	Set a property of an operator
-set-port-attribute operator-name port-name attr-name attr-value
-	Set an attribute of a port
-set-stream-attribute stream-name attr-name attr-value
-	Set an attribute of a stream
-show-queue
-	Show the queue of the plan change
-submit
-	Submit the plan change
-```
-
-
-
-## Examples
-
-An example of defining a custom macro.  The macro updates a running application by inserting a new operator.  It takes three parameters and executes a logical plan changes.
-
-```
-dt> begin-macro add-console-output
-macro> begin-logical-plan-change
-macro> create-operator $1 com.datatorrent.lib.io.ConsoleOutputOperator
-macro> create-stream stream_$1 $2 $3 $1 in
-macro> submit
-```
-
-
-Then execute the `add-console-output` macro like this
-
-```
-dt> add-console-output xyz opername portname
-```
-
-This macro then expands to run the following command
-
-```
-begin-logical-plan-change
-create-operator xyz com.datatorrent.lib.io.ConsoleOutputOperator
-create-stream stream_xyz opername portname xyz in
-submit
-```
-
-
-*Note*:  To perform runtime logical plan changes, like ability to add new operators,
-they must be part of the jar files that were deployed at application launch time.

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/images/AppConfig/ApplicationConfigurationPackages.html-image00.png
----------------------------------------------------------------------
diff --git a/images/AppConfig/ApplicationConfigurationPackages.html-image00.png b/images/AppConfig/ApplicationConfigurationPackages.html-image00.png
deleted file mode 100644
index 30ad3e4..0000000
Binary files a/images/AppConfig/ApplicationConfigurationPackages.html-image00.png and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/7af835b0/images/AppConfig/ApplicationConfigurationPackages.html-image01.png
----------------------------------------------------------------------
diff --git a/images/AppConfig/ApplicationConfigurationPackages.html-image01.png b/images/AppConfig/ApplicationConfigurationPackages.html-image01.png
deleted file mode 100644
index 5b3623d..0000000
Binary files a/images/AppConfig/ApplicationConfigurationPackages.html-image01.png and /dev/null differ