[GRIFFIN-339] Import griffin tool for debug and run user jobs

With Griffin tool, user can run dq jobs in command line.
This is helpful for user to debug and run user dq jobs.

Closes #581 from wankunde/measure_tools.

Authored-by: wankunde <wankunde@163.com>
Signed-off-by: chitralverma <chitralverma@gmail.com>
diff --git a/griffin-doc/measure/griffin-tool.md b/griffin-doc/measure/griffin-tool.md
new file mode 100644
index 0000000..31321c5
--- /dev/null
+++ b/griffin-doc/measure/griffin-tool.md
@@ -0,0 +1,144 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# Apache Griffin Shell Guide
+
+With Griffin shell, user can run dq jobs in command line. 
+This is helpful for user to debug and run user dq jobs.
+
+# Install
+
+* Compile Griffin using maven.
+* Decompress Griffin tool file `measure-x.x.x-package.tar.gz` in the target directory of measure module.
+* Install and configure spark.
+* Run Griffin tool with user defined env file and dq file. eg: `measure-x.x.x/bin/griffin-tool.sh ENV_FILE DQ_FILE`
+
+# ENV_FILE demo
+
+```json
+{
+  "spark": {
+    "log.level": "WARN",
+    "config": {
+      "spark.master": "local[*]"
+    }
+  },
+
+  "sinks": [
+    {
+      "name": "MyConsoleSink",
+      "type": "CONSOLE",
+      "config": {
+        "max.log.lines": 10
+      }
+    },
+    {
+      "name": "MyHDFSSink",
+      "type": "HDFS",
+      "config": {
+        "path": "hdfs://localhost/griffin/batch/persist",
+        "max.persist.lines": 10000,
+        "max.lines.per.file": 10000
+      }
+    },
+    {
+      "name": "MyElasticSearchSink",
+      "type": "ELASTICSEARCH",
+      "config": {
+        "method": "post",
+        "api": "http://localhost:9200/griffin/accuracy",
+        "connection.timeout": "1m",
+        "retry": 10
+      }
+    }
+  ],
+
+  "griffin.checkpoint": []
+}
+
+```
+
+# DQ file Demo
+
+```json
+{
+  "name": "accu_batch",
+  "process.type": "batch",
+  "data.sources": [
+    {
+      "name": "source",
+      "baseline": true,
+      "connector": {
+        "type": "jdbc",
+        "config": {
+          "user": "xxx",
+          "password": "xxx",
+          "tablename":  "stu",
+          "where": "id < 3",
+          "url":"jdbc:mysql://localhost:3306/test",
+          "database": "test",
+          "driver": "com.mysql.jdbc.Driver"
+        }
+      }
+    },
+    {
+      "name": "target",
+      "connector": {
+        "type": "jdbc",
+        "config": {
+          "user": "xxx",
+          "password": "xxx",
+          "tablename":  "stu2",
+          "where": "id < 3",
+          "url":"jdbc:mysql://localhost:3306/test",
+          "database": "test",
+          "driver": "com.mysql.jdbc.Driver"
+        }
+      }
+    }
+  ],
+  "evaluate.rule": {
+    "rules": [
+      {
+        "dsl.type": "griffin-dsl",
+        "dq.type": "accuracy",
+        "out.dataframe.name": "accu",
+        "rule": "source.id = target.id AND upper(source.name) = upper(target.name) ",
+        "details": {
+          "source": "source",
+          "target": "target",
+          "miss": "miss_count",
+          "total": "total_count",
+          "matched": "matched_count"
+        },
+        "out": [
+          {
+            "type": "record",
+            "name": "missRecords"
+          }
+        ]
+      }
+    ]
+  },
+  "sinks": [
+    "consoleSink"
+  ]
+}
+
+```
\ No newline at end of file
diff --git a/measure/assembly.xml b/measure/assembly.xml
new file mode 100644
index 0000000..7890497
--- /dev/null
+++ b/measure/assembly.xml
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~    http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
+  <id>package</id>
+  <formats>
+    <format>tar.gz</format>
+  </formats>
+  <fileSets>
+    <fileSet>
+      <directory>${project.basedir}/sbin</directory>
+      <outputDirectory>/bin</outputDirectory>
+      <includes>
+        <include>/**</include>
+      </includes>
+      <lineEnding>unix</lineEnding>
+      <fileMode>0777</fileMode>
+      <directoryMode>0755</directoryMode>
+    </fileSet>
+    <fileSet>
+      <directory>${project.basedir}/src/main/resources</directory>
+      <outputDirectory>/conf</outputDirectory>
+      <includes>
+        <include>/**</include>
+      </includes>
+    </fileSet>
+  </fileSets>
+
+  <dependencySets>
+    <dependencySet>
+      <useProjectArtifact>true</useProjectArtifact>
+      <outputDirectory>/lib</outputDirectory>
+      <unpack>false</unpack>
+      <scope>provided</scope>
+      <excludes>
+        <exclude>com.twitter:parquet-hadoop-bundle</exclude>
+        <exclude>io.dropwizard.metrics:*</exclude>
+        <exclude>org.glassfish.jersey.core:*</exclude>
+        <exclude>org.glassfish.jersey.containers:*</exclude>
+        <exclude>org.apache.thrift:*</exclude>
+        <exclude>org.apache.parquet:*</exclude>
+        <exclude>org.apache.hadoop:*</exclude>
+        <exclude>org.apache.spark:*</exclude>
+      </excludes>
+    </dependencySet>
+  </dependencySets>
+</assembly>
diff --git a/measure/pom.xml b/measure/pom.xml
index 460723b..a1d8f8e 100644
--- a/measure/pom.xml
+++ b/measure/pom.xml
@@ -340,6 +340,25 @@
                     </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-assembly-plugin</artifactId>
+                <configuration>
+                    <descriptors>
+                        <descriptor>assembly.xml</descriptor>
+                    </descriptors>
+                    <finalName>${artifactId}-${project.version}</finalName>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>make-assembly</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>single</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
     </build>
 </project>
diff --git a/measure/sbin/griffin-tool.sh b/measure/sbin/griffin-tool.sh
new file mode 100644
index 0000000..bff5046
--- /dev/null
+++ b/measure/sbin/griffin-tool.sh
@@ -0,0 +1,58 @@
+#!/usr/bin/env bash
+
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Logging functions
+function log_info() {
+  echo "[INFO] | $(date -u +"%D %T") UTC | $1"
+}
+
+function log_error() {
+  echo "[ERROR] | $(date -u +"%D %T") UTC | $1"
+}
+
+BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
+
+if [ ! $# -eq 2 ]; then
+  log_error "env file and dq file must be provided!"
+  exit 1
+fi
+
+env_file=$1
+if [ ! -f "${env_file}" ];then
+  log_error "Not found env file: ${env_file}"
+  exit
+fi
+shift
+
+dq_file=$1
+if [ ! -f "${dq_file}" ];then
+  log_error "Not found dq file: ${dq_file}"
+  exit
+fi
+shift
+
+cd ${BASEDIR}
+
+export JAVA_OPTS="-Xmx2048m -Xms256m -server -XX:+UseG1GC"
+
+LIB_JARS=$(echo ${BASEDIR}/lib/*.jar | tr ' ' ',')
+APP_CLASS="org.apache.griffin.measure.Application"
+APP_JAR=$(ls ${BASEDIR}/lib/measure-*.jar)
+
+exec `which spark-submit` --class ${APP_CLASS} --jars ${LIB_JARS} ${APP_JAR} ${env_file} ${dq_file}