You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@griffin.apache.org by gu...@apache.org on 2017/08/28 09:45:20 UTC

[6/6] incubator-griffin git commit: Api change

Api change

1. Modification on api
2. Add cache on hive
3. Exception handling
4. Fixes on measure deletion, add deleted and process_type to measure
5. UI change

Author: xiangrongchen <xi...@163.com>
Author: Hang-Hu <hu...@gmail.com>
Author: RachelYang2 <ln...@163.com>
Author: Yang <xi...@ebay.com>
Author: Xuan <yu...@ebay.com>
Author: dodobel <12...@qq.com>
Author: Chen <xi...@lm-shc-16501061.corp.ebay.com>
Author: Hu <ha...@ebay.com>

Closes #120 from Hang-Hu/apiChange.


Project: http://git-wip-us.apache.org/repos/asf/incubator-griffin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-griffin/commit/1cf0a99e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-griffin/tree/1cf0a99e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-griffin/diff/1cf0a99e

Branch: refs/heads/master
Commit: 1cf0a99e390371f1d7253267dd0a433e203ea03f
Parents: 5464ba5
Author: xiangrongchen <xi...@163.com>
Authored: Mon Aug 28 17:44:56 2017 +0800
Committer: William Guo <gu...@icloud.com>
Committed: Mon Aug 28 17:44:56 2017 +0800

----------------------------------------------------------------------
 .gitignore                                      |   5 +
 merge_pr.py                                     |   0
 service/pom.xml                                 |  44 ++-
 .../griffin/core/GriffinWebApplication.java     |   4 +-
 .../griffin/core/common/CacheEvictor.java       |  18 +
 .../apache/griffin/core/common/JsonConvert.java |  77 ----
 .../griffin/core/common/PropertiesOperate.java  |  54 ---
 .../griffin/core/common/SimpleCORSFilter.java   |   8 -
 .../apache/griffin/core/config/CacheConfig.java |   9 +
 .../griffin/core/config/SwaggerConfig.java      |   9 +
 .../AutowiringSpringBeanJobFactory.java         |  54 +++
 .../core/config/jobConfig/SchedulerConfig.java  |  58 +++
 .../core/config/jobConfig/SparkJobConfig.java   |  37 ++
 .../core/error/exception/GriffinException.java  |  41 ++
 .../exception/RuntimeExceptionHandler.java      |  65 ++++
 .../apache/griffin/core/job/JobController.java  |  73 ++++
 .../org/apache/griffin/core/job/JobService.java |  44 +++
 .../apache/griffin/core/job/JobServiceImpl.java | 378 +++++++++++++++++++
 .../apache/griffin/core/job/SparkSubmitJob.java | 254 +++++++++++++
 .../griffin/core/job/entity/JobHealth.java      |  49 +++
 .../griffin/core/job/entity/JobInstance.java    | 114 ++++++
 .../griffin/core/job/entity/JobRequestBody.java | 108 ++++++
 .../core/job/entity/LivySessionStates.java      |  93 +++++
 .../griffin/core/job/entity/SparkJobDO.java     | 181 +++++++++
 .../griffin/core/job/repo/JobInstanceRepo.java  |  67 ++++
 .../griffin/core/measure/AuditableEntity.java   |  86 -----
 .../griffin/core/measure/DataConnector.java     | 137 -------
 .../griffin/core/measure/EvaluateRule.java      |  56 ---
 .../apache/griffin/core/measure/Measure.java    | 136 -------
 .../griffin/core/measure/MeasureController.java |  51 +--
 .../griffin/core/measure/MeasureService.java    |  23 +-
 .../core/measure/MeasureServiceImpl.java        |  99 +++--
 .../core/measure/entity/AuditableEntity.java    |  86 +++++
 .../core/measure/entity/DataConnector.java      | 126 +++++++
 .../core/measure/entity/EvaluateRule.java       |  61 +++
 .../griffin/core/measure/entity/Measure.java    | 165 ++++++++
 .../core/measure/repo/DataConnectorRepo.java    |   2 +-
 .../core/measure/repo/EvaluateRuleRepo.java     |   2 +-
 .../griffin/core/measure/repo/MeasureRepo.java  |  16 +-
 .../core/metastore/HiveMetastoreController.java |  74 ----
 .../core/metastore/HiveMetastoreProxy.java      |  66 ----
 .../core/metastore/HiveMetastoreService.java    |  41 --
 .../metastore/HiveMetastoreServiceImpl.java     | 157 --------
 .../core/metastore/KafkaSchemaController.java   |  67 ----
 .../core/metastore/KafkaSchemaService.java      |  39 --
 .../core/metastore/KafkaSchemaServiceImpl.java  | 144 -------
 .../metastore/hive/HiveMetastoreController.java |  73 ++++
 .../core/metastore/hive/HiveMetastoreProxy.java |  78 ++++
 .../metastore/hive/HiveMetastoreService.java    |  39 ++
 .../hive/HiveMetastoreServiceImpl.java          | 155 ++++++++
 .../metastore/kafka/KafkaSchemaController.java  |  65 ++++
 .../metastore/kafka/KafkaSchemaService.java     |  39 ++
 .../metastore/kafka/KafkaSchemaServiceImpl.java | 107 ++++++
 .../griffin/core/metric/MetricController.java   |  16 +-
 .../griffin/core/metric/MetricService.java      |   2 +-
 .../core/schedule/SchedulerController.java      |  79 ----
 .../core/schedule/SchedulerRequestBody.java     | 106 ------
 .../griffin/core/schedule/SchedulerService.java |  46 ---
 .../core/schedule/SchedulerServiceImpl.java     | 302 ---------------
 .../griffin/core/schedule/SparkSubmitJob.java   | 256 -------------
 .../griffin/core/schedule/entity/JobHealth.java |  56 ---
 .../core/schedule/entity/JobInstance.java       | 100 -----
 .../core/schedule/entity/SparkJobDO.java        | 152 --------
 .../AutowiringSpringBeanJobFactory.java         |  45 ---
 .../core/schedule/quartzConfig/Conf.java        |  35 --
 .../schedule/quartzConfig/SchedulerConfig.java  |  63 ----
 .../core/schedule/repo/JobInstanceRepo.java     |  59 ---
 .../griffin/core/service/GriffinController.java |  34 +-
 .../core/util/GriffinOperationMessage.java      |  50 ++-
 .../apache/griffin/core/util/GriffinUtil.java   |  80 ++++
 .../main/resources/application-dev.properties   |  15 +-
 .../src/main/resources/application.properties   |  15 +-
 service/src/main/resources/sparkJob.properties  |  21 +-
 .../griffin/core/job/JobControllerTest.java     | 128 +++++++
 .../griffin/core/job/JobInstanceRepoTest.java   |  42 +++
 .../griffin/core/job/JobServiceImplTest.java    | 222 +++++++++++
 .../griffin/core/job/SparkSubmitJobTest.java    | 233 ++++++++++++
 .../core/measure/MeasureControllerTest.java     |  63 ++--
 .../griffin/core/measure/MeasureRepoTest.java   | 106 ++++++
 .../core/measure/MeasureServiceImplTest.java    |  71 ++--
 .../core/measure/repo/MeasureRepoTest.java      |   6 +-
 .../metastore/HiveMetastoreControllerTest.java  | 114 ------
 .../metastore/HiveMetastoreServiceImplTest.java | 162 --------
 .../metastore/KafkaSchemaControllerTest.java    | 108 ------
 .../metastore/KafkaSchemaServiceImplTest.java   | 115 ------
 .../hive/HiveMetastoreControllerTest.java       | 118 ++++++
 .../hive/HiveMetastoreServiceImplTest.java      | 167 ++++++++
 .../kafka/KafkaSchemaControllerTest.java        | 110 ++++++
 .../kafka/KafkaSchemaServiceImplTest.java       | 151 ++++++++
 .../core/metric/MetricControllerTest.java       |   2 +-
 .../core/schedule/SchedulerControllerTest.java  | 122 ------
 .../core/schedule/SchedulerServiceImplTest.java | 207 ----------
 .../core/schedule/SparkSubmitJobTest.java       | 187 ---------
 .../core/service/GriffinControllerTest.java     |  10 +-
 .../griffin/core/util/GriffinUtilTest.java      |  71 ++++
 service/src/test/resources/Init_quartz-h2.sql   | 190 ++++++++++
 .../src/test/resources/application.properties   |  21 +-
 service/src/test/resources/quartz-test.sql      |  26 ++
 service/src/test/resources/sparkJob.properties  |  52 +++
 service/src/test/resources/test.sql             |  25 ++
 ui/bower.json                                   |   1 +
 ui/css/main.css                                 |  75 +++-
 ui/img/logo.png                                 | Bin 0 -> 20582 bytes
 ui/img/spinner.gif                              | Bin 0 -> 5860 bytes
 ui/index.html                                   |  12 +-
 ui/js/bs.js                                     |   3 +-
 ui/js/controllers/createjob-ac-ctrl.js          | 168 +++++----
 ui/js/controllers/createrule-ac-ctrl.js         | 232 +++---------
 ui/js/controllers/dataassets-ctrl.js            |  27 +-
 ui/js/controllers/detail-ctrl.js                |   4 +-
 ui/js/controllers/health-ctrl.js                |  27 +-
 ui/js/controllers/job-ctrl.js                   | 261 ++++++-------
 ui/js/controllers/metrics-ctrl.js               |   2 +-
 ui/js/controllers/rule-ctrl.js                  |  19 +-
 ui/js/controllers/sidebar-ctrl.js               |  37 +-
 ui/js/controllers/viewrule-ctrl.js              |   9 +-
 ui/js/main.js                                   |   5 +
 ui/js/routes.js                                 |  12 +-
 ui/js/services/bark-chart.js                    |   2 +
 ui/js/services/services.js                      |  28 +-
 ui/login/login.html                             |   2 +-
 ui/login/login.js                               |   8 -
 ui/pages/dataassets/dataassets.html             |  15 +-
 ui/pages/health/health.html                     |   6 +
 ui/pages/jobs/confirmation-ac.html              |  12 +-
 ui/pages/jobs/createjob-ac.html                 |  46 ++-
 ui/pages/jobs/delete-confirm.html               |  10 +-
 ui/pages/jobs/jobs.html                         |  47 +--
 ui/pages/measures/measure.css                   |   2 +-
 ui/pages/measures/measures.html                 |  11 +-
 ui/sidebar.html                                 |  10 +-
 131 files changed, 5271 insertions(+), 4217 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/1cf0a99e/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 1ba27fa..3764dc9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -26,3 +26,8 @@ hs_err_pid*
 ui/bower_components/*
 
 
+
+
+ui/node_modules/*
+ui/debug.log
+ui/package-lock.json

http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/1cf0a99e/merge_pr.py
----------------------------------------------------------------------
diff --git a/merge_pr.py b/merge_pr.py
old mode 100755
new mode 100644

http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/1cf0a99e/service/pom.xml
----------------------------------------------------------------------
diff --git a/service/pom.xml b/service/pom.xml
index 58f90b6..7aecfe6 100644
--- a/service/pom.xml
+++ b/service/pom.xml
@@ -38,7 +38,6 @@ under the License.
         <hive.version>1.2.1</hive.version>
         <scala.version>2.10</scala.version>
         <spring.boot.version>1.5.1.RELEASE</spring.boot.version>
-        <spring.version>4.3.2.RELEASE</spring.version>
         <confluent.version>3.2.0</confluent.version>
         <quartz.version>2.2.1</quartz.version>
         <start-class>org.apache.griffin.core.GriffinWebApplication</start-class>
@@ -80,17 +79,8 @@ under the License.
         <dependency>
             <groupId>org.springframework.retry</groupId>
             <artifactId>spring-retry</artifactId>
-            <version>1.1.5.RELEASE</version>
         </dependency>
 
-        <!--dev db-->
-
-        <!--<dependency>-->
-            <!--<groupId>com.h2database</groupId>-->
-            <!--<artifactId>h2</artifactId>-->
-        <!--</dependency>-->
-
-
         <!--prod db-->
         <dependency>
             <groupId>mysql</groupId>
@@ -112,12 +102,22 @@ under the License.
                     <artifactId>servlet-api</artifactId>
                     <groupId>javax.servlet</groupId>
                 </exclusion>
+                <exclusion>
+                    <artifactId>guava</artifactId>
+                    <groupId>com.google.guava</groupId>
+                </exclusion>
             </exclusions>
         </dependency>
         <dependency>
             <groupId>org.apache.hive</groupId>
             <artifactId>hive-metastore</artifactId>
             <version>${hive.version}</version>
+            <exclusions>
+                <exclusion>
+                    <artifactId>guava</artifactId>
+                    <groupId>com.google.guava</groupId>
+                </exclusion>
+            </exclusions>
         </dependency>
 
         <!-- to access confluent schema registry -->
@@ -143,6 +143,13 @@ under the License.
             <version>2.2.2</version>
         </dependency>
 
+        <!--livy-core-->
+        <dependency>
+            <groupId>com.cloudera.livy</groupId>
+            <artifactId>livy-core_2.10</artifactId>
+            <version>0.3.0</version>
+        </dependency>
+
         <!-- test -->
         <dependency>
             <groupId>org.springframework.boot</groupId>
@@ -169,7 +176,24 @@ under the License.
             <scope>test</scope>
         </dependency>
 
+        <!--swagger-->
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger2</artifactId>
+            <version>2.6.1</version>
+        </dependency>
+
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger-ui</artifactId>
+            <version>2.6.1</version>
+        </dependency>
+
 
+        <dependency>
+            <groupId>com.h2database</groupId>
+            <artifactId>h2</artifactId>
+        </dependency>
     </dependencies>
     <profiles>
     </profiles>

http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/1cf0a99e/service/src/main/java/org/apache/griffin/core/GriffinWebApplication.java
----------------------------------------------------------------------
diff --git a/service/src/main/java/org/apache/griffin/core/GriffinWebApplication.java b/service/src/main/java/org/apache/griffin/core/GriffinWebApplication.java
index 38fc625..69d7d21 100644
--- a/service/src/main/java/org/apache/griffin/core/GriffinWebApplication.java
+++ b/service/src/main/java/org/apache/griffin/core/GriffinWebApplication.java
@@ -32,9 +32,9 @@ import org.springframework.scheduling.annotation.EnableScheduling;
 @SpringBootApplication
 @EnableScheduling
 public class GriffinWebApplication/* implements CommandLineRunner*/{
-    private static final Logger log = LoggerFactory.getLogger(GriffinWebApplication.class);
+    private static final Logger LOGGER = LoggerFactory.getLogger(GriffinWebApplication.class);
     public static void main(String[] args) {
-        log.info("application start");
+        LOGGER.info("application start");
         SpringApplication.run(GriffinWebApplication.class, args);
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/1cf0a99e/service/src/main/java/org/apache/griffin/core/common/CacheEvictor.java
----------------------------------------------------------------------
diff --git a/service/src/main/java/org/apache/griffin/core/common/CacheEvictor.java b/service/src/main/java/org/apache/griffin/core/common/CacheEvictor.java
new file mode 100644
index 0000000..4c4777e
--- /dev/null
+++ b/service/src/main/java/org/apache/griffin/core/common/CacheEvictor.java
@@ -0,0 +1,18 @@
+package org.apache.griffin.core.common;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+@Component
+public class CacheEvictor {
+    private static final Logger LOGGER = LoggerFactory.getLogger(CacheEvictor.class);
+
+    @Scheduled(fixedRateString = "${cache.evict.hive.fixedRate}")
+    @CacheEvict(cacheNames = "hive", allEntries = true, beforeInvocation = true)
+    public void evictHiveCache() {
+        LOGGER.info("Evict hive cache");
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/1cf0a99e/service/src/main/java/org/apache/griffin/core/common/JsonConvert.java
----------------------------------------------------------------------
diff --git a/service/src/main/java/org/apache/griffin/core/common/JsonConvert.java b/service/src/main/java/org/apache/griffin/core/common/JsonConvert.java
deleted file mode 100644
index 52f9412..0000000
--- a/service/src/main/java/org/apache/griffin/core/common/JsonConvert.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
-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.
-*/
-package org.apache.griffin.core.common;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-
-/**
- * Created by xiangrchen on 6/15/17.
- */
-public class JsonConvert {
-    private static final Logger LOGGER = LoggerFactory.getLogger(JsonConvert.class);
-
-    public static String toJson(Object obj) throws JsonProcessingException {
-        ObjectMapper mapper=new ObjectMapper();
-        String jsonStr=null;
-        jsonStr=mapper.writeValueAsString(obj);
-        return jsonStr;
-    }
-
-//    public static <T>T toEntity(String jsonStr,Class<T> type) throws IOException {
-//        if (jsonStr==null || jsonStr.length()==0){
-//            LOGGER.warn("jsonStr "+type+" is empty!");
-//            return null;
-//        }
-//        Gson gson = new Gson();
-//        return gson.fromJson(jsonStr, type);
-//    }
-
-//    public static <T>T toEntity(String jsonStr,Type type) {
-//        if (jsonStr==null || jsonStr.length()==0){
-//            LOGGER.warn("jsonStr "+type+" is empty!");
-//            return null;
-//        }
-//        Gson gson = new Gson();
-//        return gson.fromJson(jsonStr, type);
-//    }
-
-    public static <T>T toEntity(String jsonStr,Class<T> type) throws IOException {
-        if (jsonStr==null || jsonStr.length()==0){
-            LOGGER.warn("jsonStr "+type+" is empty!");
-            return null;
-        }
-        ObjectMapper mapper=new ObjectMapper();
-        return mapper.readValue(jsonStr,type);
-    }
-
-    public static <T>T toEntity(String jsonStr,TypeReference type) throws IOException {
-        if (jsonStr==null || jsonStr.length()==0){
-            LOGGER.warn("jsonStr "+type+" is empty!");
-            return null;
-        }
-        ObjectMapper mapper=new ObjectMapper();
-        return mapper.readValue(jsonStr,type);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/1cf0a99e/service/src/main/java/org/apache/griffin/core/common/PropertiesOperate.java
----------------------------------------------------------------------
diff --git a/service/src/main/java/org/apache/griffin/core/common/PropertiesOperate.java b/service/src/main/java/org/apache/griffin/core/common/PropertiesOperate.java
deleted file mode 100644
index 734762a..0000000
--- a/service/src/main/java/org/apache/griffin/core/common/PropertiesOperate.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
-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.
-*/
-package org.apache.griffin.core.common;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-
-/**
- * Created by xiangrchen on 7/13/17.
- */
-public class PropertiesOperate {
-    private static final Logger LOGGER = LoggerFactory.getLogger(PropertiesOperate.class);
-
-    public static Properties getProperties(String propFileName) throws IOException {
-        InputStream inputStream = null;
-        Properties prop = new Properties();
-        ;
-        try {
-            inputStream = PropertiesOperate.class.getClassLoader().getResourceAsStream(propFileName);
-            if (inputStream != null) {
-                prop.load(inputStream);
-            } else {
-                throw new FileNotFoundException("property file '" + propFileName + "' not found in the classpath");
-            }
-        } catch (Exception e) {
-            LOGGER.info("Exception: " + e);
-        } finally {
-            inputStream.close();
-        }
-        return prop;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/1cf0a99e/service/src/main/java/org/apache/griffin/core/common/SimpleCORSFilter.java
----------------------------------------------------------------------
diff --git a/service/src/main/java/org/apache/griffin/core/common/SimpleCORSFilter.java b/service/src/main/java/org/apache/griffin/core/common/SimpleCORSFilter.java
index 9a6bea8..b7946a3 100644
--- a/service/src/main/java/org/apache/griffin/core/common/SimpleCORSFilter.java
+++ b/service/src/main/java/org/apache/griffin/core/common/SimpleCORSFilter.java
@@ -21,15 +21,7 @@ import javax.servlet.*;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 
-//@Component
 public class SimpleCORSFilter implements Filter {
-
-// private final Logger log = LoggerFactory.getLogger(SimpleCORSFilter.class);
-//
-// public SimpleCORSFilter() {
-//    log.info("SimpleCORSFilter init");
-// }
-
     @Override
     public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
         HttpServletResponse response = (HttpServletResponse) res;

http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/1cf0a99e/service/src/main/java/org/apache/griffin/core/config/CacheConfig.java
----------------------------------------------------------------------
diff --git a/service/src/main/java/org/apache/griffin/core/config/CacheConfig.java b/service/src/main/java/org/apache/griffin/core/config/CacheConfig.java
new file mode 100644
index 0000000..d7d053a
--- /dev/null
+++ b/service/src/main/java/org/apache/griffin/core/config/CacheConfig.java
@@ -0,0 +1,9 @@
+package org.apache.griffin.core.config;
+
+import org.springframework.cache.annotation.EnableCaching;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+@EnableCaching
+public class CacheConfig {
+}

http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/1cf0a99e/service/src/main/java/org/apache/griffin/core/config/SwaggerConfig.java
----------------------------------------------------------------------
diff --git a/service/src/main/java/org/apache/griffin/core/config/SwaggerConfig.java b/service/src/main/java/org/apache/griffin/core/config/SwaggerConfig.java
new file mode 100644
index 0000000..0db85f1
--- /dev/null
+++ b/service/src/main/java/org/apache/griffin/core/config/SwaggerConfig.java
@@ -0,0 +1,9 @@
+package org.apache.griffin.core.config;
+
+import org.springframework.context.annotation.Configuration;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+@Configuration
+@EnableSwagger2
+public class SwaggerConfig {
+}

http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/1cf0a99e/service/src/main/java/org/apache/griffin/core/config/jobConfig/AutowiringSpringBeanJobFactory.java
----------------------------------------------------------------------
diff --git a/service/src/main/java/org/apache/griffin/core/config/jobConfig/AutowiringSpringBeanJobFactory.java b/service/src/main/java/org/apache/griffin/core/config/jobConfig/AutowiringSpringBeanJobFactory.java
new file mode 100644
index 0000000..3cbfc7d
--- /dev/null
+++ b/service/src/main/java/org/apache/griffin/core/config/jobConfig/AutowiringSpringBeanJobFactory.java
@@ -0,0 +1,54 @@
+/*
+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.
+*/
+
+package org.apache.griffin.core.config.jobConfig;
+
+import org.quartz.spi.TriggerFiredBundle;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.scheduling.quartz.SpringBeanJobFactory;
+
+public final class AutowiringSpringBeanJobFactory extends SpringBeanJobFactory
+		implements ApplicationContextAware {
+  private static final Logger LOGGER = LoggerFactory.getLogger(AutowiringSpringBeanJobFactory.class);
+
+	private transient AutowireCapableBeanFactory beanFactory;
+
+	@Override
+	public void setApplicationContext(final ApplicationContext context) {
+		beanFactory = context.getAutowireCapableBeanFactory();
+	}
+
+	@Override
+	protected Object createJobInstance(final TriggerFiredBundle bundle) {
+
+    try {
+      final Object job = super.createJobInstance(bundle);
+      beanFactory.autowireBean(job);
+      return job;
+
+    } catch (Exception e) {
+      LOGGER.error("fail to create job instance. "+e);
+    }
+    return null;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/1cf0a99e/service/src/main/java/org/apache/griffin/core/config/jobConfig/SchedulerConfig.java
----------------------------------------------------------------------
diff --git a/service/src/main/java/org/apache/griffin/core/config/jobConfig/SchedulerConfig.java b/service/src/main/java/org/apache/griffin/core/config/jobConfig/SchedulerConfig.java
new file mode 100644
index 0000000..2963b0e
--- /dev/null
+++ b/service/src/main/java/org/apache/griffin/core/config/jobConfig/SchedulerConfig.java
@@ -0,0 +1,58 @@
+/*
+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.
+*/
+
+package org.apache.griffin.core.config.jobConfig;
+
+import org.apache.griffin.core.util.GriffinUtil;
+import org.quartz.spi.JobFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.quartz.SchedulerFactoryBean;
+
+import javax.sql.DataSource;
+import java.util.Properties;
+
+@Configuration
+public class SchedulerConfig {
+
+	@Bean
+	public JobFactory jobFactory(ApplicationContext applicationContext) {
+		AutowiringSpringBeanJobFactory jobFactory = new AutowiringSpringBeanJobFactory();
+		jobFactory.setApplicationContext(applicationContext);
+		return jobFactory;
+	}
+
+	@Bean
+	public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource, JobFactory jobFactory) {
+		SchedulerFactoryBean factory = new SchedulerFactoryBean();
+		factory.setOverwriteExistingJobs(true);
+		factory.setDataSource(dataSource);
+		factory.setJobFactory(jobFactory);
+
+		factory.setQuartzProperties(quartzProperties());
+
+		return factory;
+	}
+
+	@Bean
+	public Properties quartzProperties() {
+		return GriffinUtil.getProperties("/quartz.properties");
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/1cf0a99e/service/src/main/java/org/apache/griffin/core/config/jobConfig/SparkJobConfig.java
----------------------------------------------------------------------
diff --git a/service/src/main/java/org/apache/griffin/core/config/jobConfig/SparkJobConfig.java b/service/src/main/java/org/apache/griffin/core/config/jobConfig/SparkJobConfig.java
new file mode 100644
index 0000000..2089ca2
--- /dev/null
+++ b/service/src/main/java/org/apache/griffin/core/config/jobConfig/SparkJobConfig.java
@@ -0,0 +1,37 @@
+/*
+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.
+*/
+
+package org.apache.griffin.core.config.jobConfig;
+
+import org.apache.griffin.core.util.GriffinUtil;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import java.util.Properties;
+
+/**
+ * Created by xiangrchen on 7/26/17.
+ */
+@Configuration
+public class SparkJobConfig {
+    @Bean(name = "sparkJobProps")
+    public Properties sparkJobProperties() {
+        return GriffinUtil.getProperties("/sparkJob.properties");
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/1cf0a99e/service/src/main/java/org/apache/griffin/core/error/exception/GriffinException.java
----------------------------------------------------------------------
diff --git a/service/src/main/java/org/apache/griffin/core/error/exception/GriffinException.java b/service/src/main/java/org/apache/griffin/core/error/exception/GriffinException.java
new file mode 100644
index 0000000..8d9d8a7
--- /dev/null
+++ b/service/src/main/java/org/apache/griffin/core/error/exception/GriffinException.java
@@ -0,0 +1,41 @@
+/*
+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.
+*/
+
+package org.apache.griffin.core.error.exception;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+/**
+ * Created by xiangrchen on 7/27/17.
+ */
+public abstract class GriffinException extends RuntimeException{
+  @ResponseStatus(value = HttpStatus.GATEWAY_TIMEOUT,reason="Fail to Connect Kafka")
+  public static class KafkaConnectionException extends GriffinException{
+  }
+  @ResponseStatus(value = HttpStatus.GATEWAY_TIMEOUT,reason="Fail to Connect Hive")
+  public static class HiveConnectionException extends GriffinException{
+  }
+  @ResponseStatus(value = HttpStatus.NOT_FOUND,reason="Fail to Get HealthInfo")
+  public static class GetHealthInfoFailureException extends GriffinException {
+  }
+  @ResponseStatus(value = HttpStatus.NOT_FOUND,reason="Fail to Get Jobs")
+  public static class GetJobsFailureException extends GriffinException {
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/1cf0a99e/service/src/main/java/org/apache/griffin/core/error/exception/RuntimeExceptionHandler.java
----------------------------------------------------------------------
diff --git a/service/src/main/java/org/apache/griffin/core/error/exception/RuntimeExceptionHandler.java b/service/src/main/java/org/apache/griffin/core/error/exception/RuntimeExceptionHandler.java
new file mode 100644
index 0000000..4d7471b
--- /dev/null
+++ b/service/src/main/java/org/apache/griffin/core/error/exception/RuntimeExceptionHandler.java
@@ -0,0 +1,65 @@
+package org.apache.griffin.core.error.exception;
+
+/*
+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.
+*/
+
+import org.apache.griffin.core.util.GriffinOperationMessage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.autoconfigure.web.DefaultErrorAttributes;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.context.request.ServletWebRequest;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Map;
+
+/**
+ * Created by xiangrchen on 7/24/17.
+ */
+@ControllerAdvice
+@ResponseBody
+public class RuntimeExceptionHandler {
+  private static final Logger LOGGER = LoggerFactory.getLogger(RuntimeExceptionHandler.class);
+
+  @ExceptionHandler(RuntimeException.class)
+  public ResponseEntity<Map<String, Object>> handleUnexpectedRuntimeException(RuntimeException e, HttpServletRequest request){
+    LOGGER.error("Unexpected RuntimeException. "+e);
+    return setExceptionResponse(request, HttpStatus.INTERNAL_SERVER_ERROR, GriffinOperationMessage.UNEXPECTED_RUNTIME_EXCEPTION);
+  }
+
+  @ExceptionHandler(value = GriffinException.class)
+  public void handleCustomException(GriffinException e) throws GriffinException {
+    throw e;
+  }
+
+  private ResponseEntity<Map<String, Object>> setExceptionResponse(HttpServletRequest request, HttpStatus status,
+      GriffinOperationMessage message) {
+    request.setAttribute("javax.servlet.error.status_code", status.value());
+    request.setAttribute("javax.servlet.error.message", message.getDescription());
+    request.setAttribute("javax.servlet.error.error", status.toString());
+    request.setAttribute("javax.servlet.error.request_uri", request.getRequestURI());
+    Map<String, Object> map=(new DefaultErrorAttributes())
+        .getErrorAttributes(new ServletWebRequest(request), false);
+    return new ResponseEntity(map, status);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/1cf0a99e/service/src/main/java/org/apache/griffin/core/job/JobController.java
----------------------------------------------------------------------
diff --git a/service/src/main/java/org/apache/griffin/core/job/JobController.java b/service/src/main/java/org/apache/griffin/core/job/JobController.java
new file mode 100644
index 0000000..ec515b2
--- /dev/null
+++ b/service/src/main/java/org/apache/griffin/core/job/JobController.java
@@ -0,0 +1,73 @@
+/*
+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.
+*/
+
+package org.apache.griffin.core.job;
+
+import org.apache.griffin.core.job.entity.JobHealth;
+import org.apache.griffin.core.job.entity.JobInstance;
+import org.apache.griffin.core.job.entity.JobRequestBody;
+import org.apache.griffin.core.util.GriffinOperationMessage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@RequestMapping("/jobs")
+public class JobController {
+    private static final Logger LOGGER = LoggerFactory.getLogger(JobController.class);
+
+    @Autowired
+    private JobService jobService;
+
+    @RequestMapping(value = "/",method = RequestMethod.GET)
+    public List<Map<String, Serializable>> getJobs() {
+        return jobService.getAliveJobs();
+    }
+
+    @RequestMapping(value = "", method = RequestMethod.POST)
+    public GriffinOperationMessage addJob(@RequestParam("group") String groupName,
+                                           @RequestParam("jobName") String jobName,
+                                           @RequestParam("measureId") Long measureId,
+                                           @RequestBody JobRequestBody jobRequestBody) {
+        return jobService.addJob(groupName,jobName, measureId, jobRequestBody);
+    }
+
+    @RequestMapping(value = "", method = RequestMethod.DELETE)
+    public GriffinOperationMessage deleteJob(@RequestParam("group") String group, @RequestParam("jobName") String jobName) {
+        return jobService.deleteJob(group,jobName);
+    }
+
+    @RequestMapping(value = "/instances",method = RequestMethod.GET)
+    public List<JobInstance> findInstancesOfJob(@RequestParam("group") String group, @RequestParam("jobName") String jobName,
+                                                @RequestParam("page") int page, @RequestParam("size") int size) {
+        return jobService.findInstancesOfJob(group,jobName,page,size);
+    }
+
+    @RequestMapping(value = "/health",method = RequestMethod.GET)
+    public JobHealth getHealthInfo()  {
+        return jobService.getHealthInfo();
+    }
+}
+
+

http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/1cf0a99e/service/src/main/java/org/apache/griffin/core/job/JobService.java
----------------------------------------------------------------------
diff --git a/service/src/main/java/org/apache/griffin/core/job/JobService.java b/service/src/main/java/org/apache/griffin/core/job/JobService.java
new file mode 100644
index 0000000..4482da5
--- /dev/null
+++ b/service/src/main/java/org/apache/griffin/core/job/JobService.java
@@ -0,0 +1,44 @@
+/*
+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.
+*/
+
+package org.apache.griffin.core.job;
+
+import org.apache.griffin.core.job.entity.JobHealth;
+import org.apache.griffin.core.job.entity.JobInstance;
+import org.apache.griffin.core.job.entity.JobRequestBody;
+import org.apache.griffin.core.util.GriffinOperationMessage;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+
+public interface JobService {
+
+    List<Map<String, Serializable>> getAliveJobs();
+
+    GriffinOperationMessage addJob(String groupName, String jobName, Long measureId, JobRequestBody jobRequestBody);
+
+    GriffinOperationMessage pauseJob(String group, String name);
+
+    GriffinOperationMessage deleteJob(String groupName,String jobName);
+
+    List<JobInstance> findInstancesOfJob(String group, String name, int page, int size);
+
+    JobHealth getHealthInfo();
+}

http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/1cf0a99e/service/src/main/java/org/apache/griffin/core/job/JobServiceImpl.java
----------------------------------------------------------------------
diff --git a/service/src/main/java/org/apache/griffin/core/job/JobServiceImpl.java b/service/src/main/java/org/apache/griffin/core/job/JobServiceImpl.java
new file mode 100644
index 0000000..41bd399
--- /dev/null
+++ b/service/src/main/java/org/apache/griffin/core/job/JobServiceImpl.java
@@ -0,0 +1,378 @@
+/*
+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.
+*/
+
+package org.apache.griffin.core.job;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import org.apache.commons.lang.StringUtils;
+import org.apache.griffin.core.error.exception.GriffinException.GetHealthInfoFailureException;
+import org.apache.griffin.core.error.exception.GriffinException.GetJobsFailureException;
+import org.apache.griffin.core.job.entity.JobHealth;
+import org.apache.griffin.core.job.entity.JobInstance;
+import org.apache.griffin.core.job.entity.JobRequestBody;
+import org.apache.griffin.core.job.entity.LivySessionStates;
+import org.apache.griffin.core.job.repo.JobInstanceRepo;
+import org.apache.griffin.core.measure.entity.Measure;
+import org.apache.griffin.core.util.GriffinOperationMessage;
+import org.apache.griffin.core.util.GriffinUtil;
+import org.quartz.*;
+import org.quartz.impl.matchers.GroupMatcher;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.domain.Sort;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.scheduling.quartz.SchedulerFactoryBean;
+import org.springframework.stereotype.Service;
+import org.springframework.web.client.RestTemplate;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.*;
+
+import static org.apache.griffin.core.util.GriffinOperationMessage.CREATE_JOB_FAIL;
+import static org.apache.griffin.core.util.GriffinOperationMessage.PAUSE_JOB_SUCCESS;
+import static org.apache.griffin.core.util.GriffinOperationMessage.SET_JOB_DELETED_STATUS_SUCCESS;
+import static org.quartz.JobBuilder.newJob;
+import static org.quartz.JobKey.jobKey;
+import static org.quartz.TriggerBuilder.newTrigger;
+import static org.quartz.TriggerKey.triggerKey;
+
+@Service
+public class JobServiceImpl implements JobService {
+    private static final Logger LOGGER = LoggerFactory.getLogger(JobServiceImpl.class);
+
+    @Autowired
+    SchedulerFactoryBean factory;
+    @Autowired
+    JobInstanceRepo jobInstanceRepo;
+    @Autowired
+    Properties sparkJobProps;
+
+    public JobServiceImpl(){
+    }
+
+    @Override
+    public List<Map<String, Serializable>> getAliveJobs() {
+        Scheduler scheduler = factory.getObject();
+        List<Map<String, Serializable>> list = new ArrayList<>();
+        try {
+            for (String groupName : scheduler.getJobGroupNames()) {
+                for (JobKey jobKey : scheduler.getJobKeys(GroupMatcher.jobGroupEquals(groupName))) {
+                    Map jobInfoMap = genJobInfoMap(scheduler, jobKey);
+                    if(jobInfoMap.size()!=0 && isJobDeleted(scheduler, jobKey) == false){
+                        list.add(jobInfoMap);
+                    }
+                }
+            }
+        } catch (SchedulerException e) {
+            LOGGER.error("failed to get running jobs."+e);
+            throw new GetJobsFailureException();
+        }
+        return list;
+    }
+
+    private boolean isJobDeleted(Scheduler scheduler, JobKey jobKey) throws SchedulerException {
+        JobDataMap jobDataMap = scheduler.getJobDetail(jobKey).getJobDataMap();
+        boolean status=jobDataMap.getBooleanFromString("deleted");
+        return status;
+    }
+
+    public Map genJobInfoMap(Scheduler scheduler,JobKey jobKey) throws SchedulerException {
+        List<Trigger> triggers = (List<Trigger>) scheduler.getTriggersOfJob(jobKey);
+        Map<String, Serializable> jobInfoMap = new HashMap<>();
+        if (triggers==null || triggers.size() == 0){
+            return jobInfoMap;
+        }
+        JobDetail jd = scheduler.getJobDetail(jobKey);
+        Date nextFireTime = triggers.get(0).getNextFireTime();
+        Date previousFireTime=triggers.get(0).getPreviousFireTime();
+        Trigger.TriggerState triggerState=scheduler.getTriggerState(triggers.get(0).getKey());
+
+        jobInfoMap.put("jobName", jobKey.getName());
+        jobInfoMap.put("groupName", jobKey.getGroup());
+        if (nextFireTime!=null){
+            jobInfoMap.put("nextFireTime", nextFireTime.getTime());
+        }
+        else {
+            jobInfoMap.put("nextFireTime", -1);
+        }
+        if (previousFireTime!=null) {
+            jobInfoMap.put("previousFireTime", previousFireTime.getTime());
+        }
+        else {
+            jobInfoMap.put("previousFireTime", -1);
+        }
+        jobInfoMap.put("triggerState",triggerState);
+        jobInfoMap.put("measureId", jd.getJobDataMap().getString("measureId"));
+        jobInfoMap.put("sourcePattern",jd.getJobDataMap().getString("sourcePattern"));
+        jobInfoMap.put("targetPattern",jd.getJobDataMap().getString("targetPattern"));
+        if(StringUtils.isNotEmpty(jd.getJobDataMap().getString("blockStartTimestamp"))) {
+            jobInfoMap.put("blockStartTimestamp", jd.getJobDataMap().getString("blockStartTimestamp"));
+        }
+        jobInfoMap.put("jobStartTime",jd.getJobDataMap().getString("jobStartTime"));
+        jobInfoMap.put("interval",jd.getJobDataMap().getString("interval"));
+        return jobInfoMap;
+    }
+
+    @Override
+    public GriffinOperationMessage addJob(String groupName, String jobName, Long measureId, JobRequestBody jobRequestBody) {
+        int interval;
+        Date jobStartTime;
+        try{
+            interval = Integer.parseInt(jobRequestBody.getInterval());
+            jobStartTime=new Date(Long.parseLong(jobRequestBody.getJobStartTime()));
+            setJobStartTime(jobStartTime,interval);
+        }catch (Exception e){
+            LOGGER.info("jobStartTime or interval format error! "+e);
+            return CREATE_JOB_FAIL;
+        }
+        try {
+            Scheduler scheduler = factory.getObject();
+            TriggerKey triggerKey = triggerKey(jobName, groupName);
+            if (scheduler.checkExists(triggerKey)) {
+                LOGGER.error("the triggerKey(jobName,groupName) "+jobName+" has been used.");
+                return CREATE_JOB_FAIL;
+                //scheduler.unscheduleJob(triggerKey);
+            }
+            JobKey jobKey = jobKey(jobName, groupName);
+            JobDetail jobDetail;
+            if (scheduler.checkExists(jobKey)) {
+                jobDetail = scheduler.getJobDetail(jobKey);
+                setJobData(jobDetail, jobRequestBody, measureId, groupName, jobName);
+                scheduler.addJob(jobDetail, true);
+            } else {
+                jobDetail = newJob(SparkSubmitJob.class)
+                        .storeDurably()
+                        .withIdentity(jobKey)
+                        .build();
+                //set JobData
+                setJobData(jobDetail, jobRequestBody, measureId, groupName, jobName);
+                scheduler.addJob(jobDetail, false);
+            }
+            Trigger trigger = newTrigger()
+                    .withIdentity(triggerKey)
+                    .forJob(jobDetail)
+                    .withSchedule(SimpleScheduleBuilder.simpleSchedule()
+                            .withIntervalInSeconds(interval)
+                            .repeatForever())
+                    .startAt(jobStartTime)
+                    .build();
+            scheduler.scheduleJob(trigger);
+            return GriffinOperationMessage.CREATE_JOB_SUCCESS;
+        } catch (SchedulerException e) {
+            LOGGER.error("SchedulerException when add job.", e);
+            return CREATE_JOB_FAIL;
+        }
+    }
+
+    public void setJobStartTime(Date jobStartTime,int interval){
+        long currentTimestamp=System.currentTimeMillis();
+        long jobstartTimestamp=jobStartTime.getTime();
+        //if jobStartTime is before currentTimestamp, reset it with a future time
+        if(jobStartTime.before(new Date(currentTimestamp))){
+            long n=(currentTimestamp-jobstartTimestamp)/(long)(interval*1000);
+            jobstartTimestamp=jobstartTimestamp+(n+1)*(long)(interval*1000);
+            jobStartTime.setTime(jobstartTimestamp);
+        }
+    }
+
+    public void setJobData(JobDetail jobDetail, JobRequestBody jobRequestBody, Long measureId, String groupName, String jobName){
+        jobDetail.getJobDataMap().put("groupName",groupName);
+        jobDetail.getJobDataMap().put("jobName",jobName);
+        jobDetail.getJobDataMap().put("measureId", measureId.toString());
+        jobDetail.getJobDataMap().put("sourcePattern", jobRequestBody.getSourcePattern());
+        jobDetail.getJobDataMap().put("targetPattern", jobRequestBody.getTargetPattern());
+        jobDetail.getJobDataMap().put("blockStartTimestamp", jobRequestBody.getBlockStartTimestamp());
+        jobDetail.getJobDataMap().put("jobStartTime", jobRequestBody.getJobStartTime());
+        jobDetail.getJobDataMap().put("interval", jobRequestBody.getInterval());
+        jobDetail.getJobDataMap().put("lastBlockStartTimestamp", "");
+        jobDetail.getJobDataMap().putAsString("deleted", false);
+    }
+
+    @Override
+    public GriffinOperationMessage pauseJob(String group, String name){
+        try {
+            Scheduler scheduler = factory.getObject();
+            scheduler.pauseJob(new JobKey(name, group));
+            return GriffinOperationMessage.PAUSE_JOB_SUCCESS;
+        } catch (SchedulerException e) {
+            LOGGER.error(GriffinOperationMessage.PAUSE_JOB_FAIL+""+e);
+            return GriffinOperationMessage.PAUSE_JOB_FAIL;
+        }
+    }
+
+    private GriffinOperationMessage setJobDeleted(String group, String name){
+        try {
+            Scheduler scheduler = factory.getObject();
+            JobDetail jobDetail=scheduler.getJobDetail(new JobKey(name, group));
+            jobDetail.getJobDataMap().putAsString("deleted", true);
+            scheduler.addJob(jobDetail, true);
+            return GriffinOperationMessage.SET_JOB_DELETED_STATUS_SUCCESS;
+        } catch (SchedulerException e) {
+            LOGGER.error(GriffinOperationMessage.PAUSE_JOB_FAIL+""+e);
+            return GriffinOperationMessage.SET_JOB_DELETED_STATUS_FAIL;
+        }
+    }
+
+    /**
+     * logically delete
+     * 1. pause these jobs
+     * 2. set these jobs as deleted status
+     * @param group
+     * @param name
+     * @return
+     */
+    @Override
+    public GriffinOperationMessage deleteJob(String group, String name) {
+        //logically delete
+        if (pauseJob(group,name).equals(PAUSE_JOB_SUCCESS) &&
+                setJobDeleted(group, name).equals(SET_JOB_DELETED_STATUS_SUCCESS)){
+            return GriffinOperationMessage.DELETE_JOB_SUCCESS;
+        }
+        return GriffinOperationMessage.DELETE_JOB_FAIL;
+    }
+
+    /**
+     * deleteJobsRelateToMeasure
+     * 1. search jobs related to measure
+     * 2. deleteJob
+     * @param measure
+     */
+    public void deleteJobsRelateToMeasure(Measure measure) {
+        Scheduler scheduler = factory.getObject();
+        try {
+            for(JobKey jobKey: scheduler.getJobKeys(GroupMatcher.anyGroup())){//get all jobs
+                JobDetail jobDetail = scheduler.getJobDetail(jobKey);
+                JobDataMap jobDataMap = jobDetail.getJobDataMap();
+                if(jobDataMap.getString("measureId").equals(measure.getId().toString())){
+                    //select jobs related to measureId,
+                    deleteJob(jobKey.getGroup(),jobKey.getName());
+                    LOGGER.info(jobKey.getGroup()+" "+jobKey.getName()+" is paused and logically deleted.");
+                }
+            }
+        } catch (SchedulerException e) {
+            LOGGER.error("Fail to stop jobs related to measure id: " + measure.getId()+"name: "+measure.getName());
+        }
+    }
+
+    @Override
+    public List<JobInstance> findInstancesOfJob(String group, String jobName, int page, int size) {
+        //query and return instances
+        Pageable pageRequest=new PageRequest(page,size, Sort.Direction.DESC,"timestamp");
+        return jobInstanceRepo.findByGroupNameAndJobName(group,jobName,pageRequest);
+    }
+
+    @Scheduled(fixedDelayString = "${jobInstance.fixedDelay.in.milliseconds}")
+    public void syncInstancesOfAllJobs(){
+        List<Object> groupJobList=jobInstanceRepo.findGroupWithJobName();
+        for (Object groupJobObj : groupJobList){
+            try{
+                Object[] groupJob=(Object[])groupJobObj;
+                if (groupJob!=null && groupJob.length==2){
+                    syncInstancesOfJob(groupJob[0].toString(),groupJob[1].toString());
+                }
+            }catch (Exception e){
+                LOGGER.error("schedule update instances of all jobs failed. "+e);
+            }
+        }
+    }
+
+    /**
+     * call livy to update jobInstance table in mysql.
+     * @param group
+     * @param jobName
+     */
+    public void syncInstancesOfJob(String group, String jobName) {
+        //update all instance info belongs to this group and job.
+        List<JobInstance> jobInstanceList=jobInstanceRepo.findByGroupNameAndJobName(group,jobName);
+        for (JobInstance jobInstance:jobInstanceList){
+            if (!LivySessionStates.isActive(jobInstance.getState())){
+                continue;
+            }
+            String uri=sparkJobProps.getProperty("livy.uri")+"/"+jobInstance.getSessionId();
+            RestTemplate restTemplate=new RestTemplate();
+            String resultStr=null;
+            try{
+                resultStr=restTemplate.getForObject(uri,String.class);
+            }catch (Exception e){
+                LOGGER.error("spark session "+jobInstance.getSessionId()+" has overdue, set state as unknown!\n"+e);
+                //if server cannot get session from Livy, set State as unknown.
+                jobInstance.setState(LivySessionStates.State.unknown);
+                jobInstanceRepo.save(jobInstance);
+                continue;
+            }
+            TypeReference<HashMap<String,Object>> type=new TypeReference<HashMap<String,Object>>(){};
+            HashMap<String,Object> resultMap;
+            try {
+                resultMap = GriffinUtil.toEntity(resultStr,type);
+            } catch (IOException e) {
+                LOGGER.error("jobInstance jsonStr convert to map failed. "+e);
+                continue;
+            }
+            try{
+                if (resultMap!=null && resultMap.size()!=0){
+                    jobInstance.setState(LivySessionStates.State.valueOf(resultMap.get("state").toString()));
+                    jobInstance.setAppId(resultMap.get("appId").toString());
+                    jobInstance.setAppUri(sparkJobProps.getProperty("spark.uri")+"/cluster/app/"+resultMap.get("appId").toString());
+                }
+            }catch (Exception e){
+                LOGGER.warn(group+","+jobName+"job Instance has some null field (state or appId). "+e);
+                continue;
+            }
+            jobInstanceRepo.save(jobInstance);
+        }
+    }
+
+    /**
+     * a job is regard as healthy job when its latest instance is in healthy state.
+     * @return
+     */
+    @Override
+    public JobHealth getHealthInfo()  {
+        Scheduler scheduler=factory.getObject();
+        int jobCount= 0;
+        int notHealthyCount=0;
+        try {
+            for (String groupName : scheduler.getJobGroupNames()){
+                for (JobKey jobKey : scheduler.getJobKeys(GroupMatcher.jobGroupEquals(groupName))){
+                    jobCount++;
+                    String jobName=jobKey.getName();
+                    String jobGroup=jobKey.getGroup();
+                    Pageable pageRequest=new PageRequest(0,1, Sort.Direction.DESC,"timestamp");
+                    JobInstance latestJobInstance;
+                    if (jobInstanceRepo.findByGroupNameAndJobName(jobGroup,jobName,pageRequest)!=null
+                            &&jobInstanceRepo.findByGroupNameAndJobName(jobGroup,jobName,pageRequest).size()>0){
+                        latestJobInstance=jobInstanceRepo.findByGroupNameAndJobName(jobGroup,jobName,pageRequest).get(0);
+                        if(!LivySessionStates.isHeathy(latestJobInstance.getState())){
+                            notHealthyCount++;
+                        }
+                    }
+                }
+            }
+        } catch (SchedulerException e) {
+            LOGGER.error(""+e);
+            throw new GetHealthInfoFailureException();
+        }
+        JobHealth jobHealth=new JobHealth(jobCount-notHealthyCount,jobCount);
+        return jobHealth;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/1cf0a99e/service/src/main/java/org/apache/griffin/core/job/SparkSubmitJob.java
----------------------------------------------------------------------
diff --git a/service/src/main/java/org/apache/griffin/core/job/SparkSubmitJob.java b/service/src/main/java/org/apache/griffin/core/job/SparkSubmitJob.java
new file mode 100644
index 0000000..47157e0
--- /dev/null
+++ b/service/src/main/java/org/apache/griffin/core/job/SparkSubmitJob.java
@@ -0,0 +1,254 @@
+/*
+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.
+*/
+
+package org.apache.griffin.core.job;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectWriter;
+import org.apache.commons.lang.StringUtils;
+import org.apache.griffin.core.job.entity.JobInstance;
+import org.apache.griffin.core.job.entity.LivySessionStates;
+import org.apache.griffin.core.job.entity.SparkJobDO;
+import org.apache.griffin.core.job.repo.JobInstanceRepo;
+import org.apache.griffin.core.measure.entity.DataConnector;
+import org.apache.griffin.core.measure.entity.Measure;
+import org.apache.griffin.core.measure.repo.MeasureRepo;
+import org.apache.griffin.core.util.GriffinUtil;
+import org.quartz.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.client.RestTemplate;
+
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+@PersistJobDataAfterExecution
+@DisallowConcurrentExecution
+public class SparkSubmitJob implements Job {
+    private static final Logger LOGGER = LoggerFactory.getLogger(SparkSubmitJob.class);
+
+    @Autowired
+    private MeasureRepo measureRepo;
+    @Autowired
+    private JobInstanceRepo jobInstanceRepo;
+    @Autowired
+    private Properties sparkJobProps;
+
+    /**
+     * partitionItems
+     * for example
+     * partitionItems like "date","hour",...
+     */
+    private String[] partitionItems;
+    /**
+     * sourcePatternItems targetPatternItems
+     * for example
+     * sourcePatternItems or targetPatternItems is like "YYYYMMDD","HH",...
+     */
+    private String[] sourcePatternItems,targetPatternItems;
+
+    private Measure measure;
+    private String sourcePattern,targetPattern;
+    private String blockStartTimestamp,lastBlockStartTimestamp;
+    private String interval;
+    private String uri;
+    private RestTemplate restTemplate = new RestTemplate();
+    private SparkJobDO sparkJobDO = new SparkJobDO();
+
+    public SparkSubmitJob() {
+    }
+
+    /**
+     * execute method is used to submit sparkJobDO to Livy.
+     * @param context
+     */
+    @Override
+    public void execute(JobExecutionContext context) {
+        JobDetail jd = context.getJobDetail();
+        String groupName=jd.getJobDataMap().getString("groupName");
+        String jobName=jd.getJobDataMap().getString("jobName");
+        init(jd);
+        //prepare current system timestamp
+        long currentblockStartTimestamp = setCurrentblockStartTimestamp(System.currentTimeMillis());
+        LOGGER.info("currentblockStartTimestamp: "+currentblockStartTimestamp);
+        if (StringUtils.isNotEmpty(sourcePattern)) {
+            sourcePatternItems = sourcePattern.split("-");
+            setDataConnectorPartitions(measure.getSource(), sourcePatternItems, partitionItems, currentblockStartTimestamp);
+        }
+        if (StringUtils.isNotEmpty(targetPattern)) {
+            targetPatternItems = targetPattern.split("-");
+            setDataConnectorPartitions(measure.getTarget(), targetPatternItems, partitionItems, currentblockStartTimestamp);
+        }
+        jd.getJobDataMap().put("lastBlockStartTimestamp", currentblockStartTimestamp + "");
+        setSparkJobDO();
+        String result = restTemplate.postForObject(uri, sparkJobDO, String.class);
+        LOGGER.info(result);
+        saveJobInstance(groupName,jobName,result);
+    }
+
+    public void init(JobDetail jd){
+        //jd.getJobDataMap().getString()
+        /**
+         * the field measureId is generated from `setJobData` in `JobServiceImpl`
+         */
+        String measureId = jd.getJobDataMap().getString("measureId");
+        measure = measureRepo.findOne(Long.valueOf(measureId));
+        if (measure==null) {
+            LOGGER.error("Measure with id " + measureId + " is not find!");
+            //if return here, livy uri won't be set, and will keep null for all measures even they are not null
+        }
+        String partitionItemstr = sparkJobProps.getProperty("sparkJob.dateAndHour");
+        partitionItems = partitionItemstr.split(",");
+        uri = sparkJobProps.getProperty("livy.uri");
+        sourcePattern = jd.getJobDataMap().getString("sourcePattern");
+        targetPattern = jd.getJobDataMap().getString("targetPattern");
+        blockStartTimestamp = jd.getJobDataMap().getString("blockStartTimestamp");
+        lastBlockStartTimestamp = jd.getJobDataMap().getString("lastBlockStartTimestamp");
+        LOGGER.info("lastBlockStartTimestamp:"+lastBlockStartTimestamp);
+        interval = jd.getJobDataMap().getString("interval");
+    }
+
+    private void setDataConnectorPartitions(DataConnector dc, String[] patternItemSet, String[] partitionItems, long timestamp) {
+        Map<String, String> partitionItemMap = genPartitionMap(patternItemSet, partitionItems, timestamp);
+        /**
+         * partitions must be a string like: "dt=20170301, hour=12"
+         * partitionItemMap.toString() is like "{dt=20170301, hour=12}"
+         */
+        String partitions = partitionItemMap.toString().substring(1, partitionItemMap.toString().length() - 1);
+        Map<String, String> configMap = dc.getConfigInMaps();
+        //config should not be null
+        configMap.put("partitions", partitions);
+        try {
+            dc.setConfig(configMap);
+        } catch (JsonProcessingException e) {
+            LOGGER.error(""+e);
+        }
+    }
+
+    public Map<String, String> genPartitionMap(String[] patternItemSet, String[] partitionItems, long timestamp) {
+        /**
+         * patternItemSet:{YYYYMMdd,HH}
+         * partitionItems:{dt,hour}
+         * partitionItemMap:{dt=20170804,hour=09}
+         */
+        int comparableSizeMin=Math.min(patternItemSet.length,partitionItems.length);
+        Map<String, String> partitionItemMap = new HashMap<>();
+        for (int i = 0; i < comparableSizeMin; i++) {
+            /**
+             * in order to get a standard date like 20170427 01 (YYYYMMdd-HH)
+             */
+            String pattrn = patternItemSet[i].replace("mm", "MM");
+            pattrn = pattrn.replace("DD", "dd");
+            pattrn = pattrn.replace("hh", "HH");
+            SimpleDateFormat sdf = new SimpleDateFormat(pattrn);
+            partitionItemMap.put(partitionItems[i], sdf.format(new Date(timestamp)));
+        }
+        return partitionItemMap;
+    }
+
+
+    public long setCurrentblockStartTimestamp(long currentSystemTimestamp) {
+        long currentblockStartTimestamp=0;
+        if (StringUtils.isNotEmpty(lastBlockStartTimestamp)) {
+            try {
+                currentblockStartTimestamp = Long.parseLong(lastBlockStartTimestamp) + Integer.parseInt(interval) * 1000;
+            }catch (Exception e){
+                LOGGER.info("lastBlockStartTimestamp or interval format problem! "+e);
+            }
+        } else {
+            if (StringUtils.isNotEmpty(blockStartTimestamp)) {
+                try{
+                    currentblockStartTimestamp = Long.parseLong(blockStartTimestamp);
+                }catch (Exception e){
+                    LOGGER.info("blockStartTimestamp format problem! "+e);
+                }
+            } else {
+                currentblockStartTimestamp = currentSystemTimestamp;
+            }
+        }
+        return currentblockStartTimestamp;
+    }
+
+    public void setSparkJobDO() {
+        sparkJobDO.setFile(sparkJobProps.getProperty("sparkJob.file"));
+        sparkJobDO.setClassName(sparkJobProps.getProperty("sparkJob.className"));
+
+        List<String> args = new ArrayList<String>();
+        args.add(sparkJobProps.getProperty("sparkJob.args_1"));
+        ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
+        String measureJson = "";
+        try {
+            measureJson = ow.writeValueAsString(measure);
+        } catch (JsonProcessingException e) {
+            e.printStackTrace();
+        }
+        args.add(measureJson);  //partition
+        args.add(sparkJobProps.getProperty("sparkJob.args_3"));
+        sparkJobDO.setArgs(args);
+
+        sparkJobDO.setName(sparkJobProps.getProperty("sparkJob.name"));
+        sparkJobDO.setQueue(sparkJobProps.getProperty("sparkJob.queue"));
+        sparkJobDO.setNumExecutors(Long.parseLong(sparkJobProps.getProperty("sparkJob.numExecutors")));
+        sparkJobDO.setExecutorCores(Long.parseLong(sparkJobProps.getProperty("sparkJob.executorCores")));
+        sparkJobDO.setDriverMemory(sparkJobProps.getProperty("sparkJob.driverMemory"));
+        sparkJobDO.setExecutorMemory(sparkJobProps.getProperty("sparkJob.executorMemory"));
+
+        Map<String,String> conf=new HashMap<String,String>();
+        conf.put("spark.jars.packages",sparkJobProps.getProperty("sparkJob.spark.jars.packages"));
+        sparkJobDO.setConf(conf);
+
+        List<String> jars = new ArrayList<>();
+        jars.add(sparkJobProps.getProperty("sparkJob.jars_1"));
+        jars.add(sparkJobProps.getProperty("sparkJob.jars_2"));
+        jars.add(sparkJobProps.getProperty("sparkJob.jars_3"));
+        sparkJobDO.setJars(jars);
+
+        List<String> files = new ArrayList<>();
+        sparkJobDO.setFiles(files);
+    }
+
+    public void saveJobInstance(String groupName,String jobName,String result){
+        //save JobInstance info into DataBase
+        Map<String,Object> resultMap=new HashMap<String,Object>();
+        TypeReference<HashMap<String,Object>> type=new TypeReference<HashMap<String,Object>>(){};
+        try {
+            resultMap= GriffinUtil.toEntity(result,type);
+        } catch (IOException e) {
+            LOGGER.error("jobInstance jsonStr convert to map failed. "+e);
+        }
+        JobInstance jobInstance=new JobInstance();
+        if(resultMap!=null) {
+            jobInstance.setGroupName(groupName);
+            jobInstance.setJobName(jobName);
+            try {
+                jobInstance.setSessionId(Integer.parseInt(resultMap.get("id").toString()));
+                jobInstance.setState(LivySessionStates.State.valueOf(resultMap.get("state").toString()));
+                jobInstance.setAppId(resultMap.get("appId").toString());
+            }catch (Exception e){
+                LOGGER.warn("jobInstance has null field. "+e);
+            }
+            jobInstance.setTimestamp(System.currentTimeMillis());
+            jobInstanceRepo.save(jobInstance);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/1cf0a99e/service/src/main/java/org/apache/griffin/core/job/entity/JobHealth.java
----------------------------------------------------------------------
diff --git a/service/src/main/java/org/apache/griffin/core/job/entity/JobHealth.java b/service/src/main/java/org/apache/griffin/core/job/entity/JobHealth.java
new file mode 100644
index 0000000..9d2a654
--- /dev/null
+++ b/service/src/main/java/org/apache/griffin/core/job/entity/JobHealth.java
@@ -0,0 +1,49 @@
+/*
+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.
+*/
+package org.apache.griffin.core.job.entity;
+
+
+public class JobHealth {
+    private int healthyJobCount;
+    private int jobCount;
+
+    public int getHealthyJobCount() {
+        return healthyJobCount;
+    }
+
+    public void setHealthyJobCount(int healthyJobCount) {
+        this.healthyJobCount = healthyJobCount;
+    }
+
+    public int getJobCount() {
+        return jobCount;
+    }
+
+    public void setJobCount(int jobCount) {
+        this.jobCount = jobCount;
+    }
+
+    public JobHealth() {
+    }
+
+    public JobHealth(int healthyJobCount, int jobCount) {
+        this.healthyJobCount = healthyJobCount;
+        this.jobCount = jobCount;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/1cf0a99e/service/src/main/java/org/apache/griffin/core/job/entity/JobInstance.java
----------------------------------------------------------------------
diff --git a/service/src/main/java/org/apache/griffin/core/job/entity/JobInstance.java b/service/src/main/java/org/apache/griffin/core/job/entity/JobInstance.java
new file mode 100644
index 0000000..ab90dd3
--- /dev/null
+++ b/service/src/main/java/org/apache/griffin/core/job/entity/JobInstance.java
@@ -0,0 +1,114 @@
+/*
+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.
+*/
+
+package org.apache.griffin.core.job.entity;
+
+import org.apache.griffin.core.job.entity.LivySessionStates.State;
+import org.apache.griffin.core.measure.entity.AuditableEntity;
+
+import javax.persistence.*;
+
+/**
+ * Created by xiangrchen on 5/31/17.
+ */
+@Entity
+public class JobInstance extends AuditableEntity {
+
+    private static final long serialVersionUID = -4748881017029815874L;
+
+    private String groupName;
+    private String jobName;
+    private int sessionId;
+    @Enumerated(EnumType.STRING)
+    State state;
+    String appId;
+    @Lob
+    @Column(length=1024) //2^10=1024
+    private String appUri;
+    long timestamp;
+
+    public String getGroupName() {
+        return groupName;
+    }
+
+    public void setGroupName(String groupName) {
+        this.groupName = groupName;
+    }
+
+    public String getJobName() {
+        return jobName;
+    }
+
+    public void setJobName(String jobName) {
+        this.jobName = jobName;
+    }
+
+    public int getSessionId() {
+        return sessionId;
+    }
+
+    public void setSessionId(int sessionId) {
+        this.sessionId = sessionId;
+    }
+
+    public State getState() {
+        return state;
+    }
+
+    public void setState(State state) {
+        this.state = state;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+
+    public void setAppId(String appId) {
+        this.appId = appId;
+    }
+
+    public String getAppUri() {
+        return appUri;
+    }
+
+    public void setAppUri(String appUri) {
+        this.appUri = appUri;
+    }
+
+    public long getTimestamp() {
+        return timestamp;
+    }
+
+    public void setTimestamp(long timestamp) {
+        this.timestamp = timestamp;
+    }
+
+    public JobInstance() {
+    }
+
+    public JobInstance(String groupName, String jobName, int sessionId, State state, String appId, String appUri, long timestamp) {
+        this.groupName = groupName;
+        this.jobName = jobName;
+        this.sessionId = sessionId;
+        this.state = state;
+        this.appId = appId;
+        this.appUri = appUri;
+        this.timestamp = timestamp;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/1cf0a99e/service/src/main/java/org/apache/griffin/core/job/entity/JobRequestBody.java
----------------------------------------------------------------------
diff --git a/service/src/main/java/org/apache/griffin/core/job/entity/JobRequestBody.java b/service/src/main/java/org/apache/griffin/core/job/entity/JobRequestBody.java
new file mode 100644
index 0000000..796949e
--- /dev/null
+++ b/service/src/main/java/org/apache/griffin/core/job/entity/JobRequestBody.java
@@ -0,0 +1,108 @@
+/*
+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.
+*/
+package org.apache.griffin.core.job.entity;
+
+/**
+ * Created by xiangrchen on 4/27/17.
+ */
+public class JobRequestBody {
+    private String sourcePattern;
+    private String targetPattern;
+    private String blockStartTimestamp;
+    private String jobStartTime;
+    private String interval;
+
+    public String getSourcePattern() {
+        return sourcePattern;
+    }
+
+    public void setSourcePattern(String sourcePattern) {
+        this.sourcePattern = sourcePattern;
+    }
+
+    public String getTargetPattern() {
+        return targetPattern;
+    }
+
+    public void setTargetPattern(String targetPattern) {
+        this.targetPattern = targetPattern;
+    }
+
+    public String getBlockStartTimestamp() {
+        return blockStartTimestamp;
+    }
+
+    public void setBlockStartTimestamp(String blockStartTimestamp) {
+        this.blockStartTimestamp = blockStartTimestamp;
+    }
+
+    public String getJobStartTime() {
+        return jobStartTime;
+    }
+
+    public void setJobStartTime(String jobStartTime) {
+        this.jobStartTime = jobStartTime;
+    }
+
+    public String getInterval() {
+        return interval;
+    }
+
+    public void setInterval(String interval) {
+        this.interval = interval;
+    }
+
+    public JobRequestBody() {
+    }
+
+    public JobRequestBody(String sourcePattern, String targetPattern, String blockStartTimestamp, String jobStartTime, String interval) {
+        this.sourcePattern = sourcePattern;
+        this.targetPattern = targetPattern;
+        this.blockStartTimestamp = blockStartTimestamp;
+        this.jobStartTime = jobStartTime;
+        this.interval = interval;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        JobRequestBody that = (JobRequestBody) o;
+
+        if (sourcePattern != null ? !sourcePattern.equals(that.sourcePattern) : that.sourcePattern != null)
+            return false;
+        if (targetPattern != null ? !targetPattern.equals(that.targetPattern) : that.targetPattern != null)
+            return false;
+        if (blockStartTimestamp != null ? !blockStartTimestamp.equals(that.blockStartTimestamp) : that.blockStartTimestamp != null)
+            return false;
+        if (jobStartTime != null ? !jobStartTime.equals(that.jobStartTime) : that.jobStartTime != null) return false;
+        return interval != null ? interval.equals(that.interval) : that.interval == null;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = sourcePattern != null ? sourcePattern.hashCode() : 0;
+        result = 31 * result + (targetPattern != null ? targetPattern.hashCode() : 0);
+        result = 31 * result + (blockStartTimestamp != null ? blockStartTimestamp.hashCode() : 0);
+        result = 31 * result + (jobStartTime != null ? jobStartTime.hashCode() : 0);
+        result = 31 * result + (interval != null ? interval.hashCode() : 0);
+        return result;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/1cf0a99e/service/src/main/java/org/apache/griffin/core/job/entity/LivySessionStates.java
----------------------------------------------------------------------
diff --git a/service/src/main/java/org/apache/griffin/core/job/entity/LivySessionStates.java b/service/src/main/java/org/apache/griffin/core/job/entity/LivySessionStates.java
new file mode 100644
index 0000000..989bc44
--- /dev/null
+++ b/service/src/main/java/org/apache/griffin/core/job/entity/LivySessionStates.java
@@ -0,0 +1,93 @@
+/*
+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.
+*/
+
+package org.apache.griffin.core.job.entity;
+
+import com.cloudera.livy.sessions.SessionState;
+
+/**
+ * Created by xiangrchen on 7/31/17.
+ */
+public class LivySessionStates {
+
+    /**
+     * unknown is used to represent the state that server get null from Livy.
+     * the other state is just same as com.cloudera.livy.sessions.SessionState.
+     */
+    public enum State {
+        not_started,
+        starting,
+        recovering,
+        idle,
+        running,
+        busy,
+        shutting_down,
+        error,
+        dead,
+        success,
+        unknown
+    }
+
+    public static SessionState toSessionState(State state){
+        switch (state){
+            case not_started:
+                return new SessionState.NotStarted();
+            case starting:
+                return new SessionState.Starting();
+            case recovering:
+                return new SessionState.Recovering();
+            case idle:
+                return new SessionState.Idle();
+            case running:
+                return new SessionState.Running();
+            case busy:
+                return new SessionState.Busy();
+            case shutting_down:
+                return new SessionState.ShuttingDown();
+            case error:
+                return new SessionState.Error(System.nanoTime());
+            case dead:
+                return new SessionState.Dead(System.nanoTime());
+            case success:
+                return new SessionState.Success(System.nanoTime());
+            default:
+                return null;
+        }
+    }
+
+    public static boolean isActive(State state){
+        if (State.unknown.equals(state)){
+            // set unknown isactive() as false.
+            return false;
+        }
+        SessionState sessionState=toSessionState(state);
+        if (sessionState==null){
+            return false;
+        }else {
+            return sessionState.isActive();
+        }
+    }
+
+    public static boolean isHeathy(State state){
+        if (State.error.equals(state) || State.dead.equals(state) || State.shutting_down.equals(state)){
+            return false;
+        }
+        return true;
+    }
+}