You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by di...@apache.org on 2020/01/07 05:50:50 UTC

[airavata-mft] branch master updated: Adding grpc api for external clients

This is an automated email from the ASF dual-hosted git repository.

dimuthuupe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-mft.git


The following commit(s) were added to refs/heads/master by this push:
     new 94422d9  Adding grpc api for external clients
94422d9 is described below

commit 94422d9c5dc8af8c4f09e950b4765ccdfd824d9f
Author: Dimuthu Wannipurage <di...@gmail.com>
AuthorDate: Tue Jan 7 00:50:35 2020 -0500

    Adding grpc api for external clients
---
 api/api-entities/pom.xml                           | 36 +++++++++
 .../mft/api}/db/entities/TargetAgentEntity.java    |  2 +-
 .../mft/api}/db/entities/TargetAgentPK.java        |  2 +-
 .../mft/api}/db/entities/TransferEntity.java       |  2 +-
 .../api}/db/entities/TransferExecutionEntity.java  |  2 +-
 .../mft/api}/db/entities/TransferStatusEntity.java | 12 +--
 .../db/repositories/TargetAgentRepository.java     |  6 +-
 .../api}/db/repositories/TransferRepository.java   |  6 +-
 .../db/repositories/TransferStatusRepository.java  | 13 ++-
 api/client/pom.xml                                 | 43 ++++++++++
 .../airavata/mft/api/client/MFTApiClient.java      | 44 ++++++++++
 api/pom.xml                                        | 70 ++++++++++++++++
 api/service/pom.xml                                | 65 +++++++++++++++
 .../airavata/mft/api/ApiServiceApplication.java    | 14 +++-
 .../org/apache/airavata/mft/api/AppConfig.java     | 48 +++++++++++
 .../airavata/mft/api/handler/MFTApiHandler.java    | 94 ++++++++++++++++++++++
 .../src/main/resources/application.properties      | 10 ++-
 api/service/src/main/resources/logback.xml         | 54 +++++++++++++
 api/stub/pom.xml                                   | 64 +++++++++++++++
 api/stub/src/main/proto/MFTApi.proto               | 57 +++++++++++++
 controller/pom.xml                                 | 11 +++
 ...ransferStatusRepository.java => AppConfig.java} |  8 +-
 .../airavata/mft/controller/MFTController.java     | 17 ++--
 .../src/main/resources/application.properties      |  8 +-
 pom.xml                                            |  1 +
 25 files changed, 657 insertions(+), 32 deletions(-)

diff --git a/api/api-entities/pom.xml b/api/api-entities/pom.xml
new file mode 100644
index 0000000..b5f9f13
--- /dev/null
+++ b/api/api-entities/pom.xml
@@ -0,0 +1,36 @@
+<?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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>mft-api</artifactId>
+        <groupId>org.apache.airavata</groupId>
+        <version>0.01-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>mft-api-entities</artifactId>
+
+
+</project>
\ No newline at end of file
diff --git a/controller/src/main/java/org/apache/airavata/mft/controller/db/entities/TargetAgentEntity.java b/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/entities/TargetAgentEntity.java
similarity index 97%
rename from controller/src/main/java/org/apache/airavata/mft/controller/db/entities/TargetAgentEntity.java
rename to api/api-entities/src/main/java/org/apache/airavata/mft/api/db/entities/TargetAgentEntity.java
index 056df7e..8c24cf4 100644
--- a/controller/src/main/java/org/apache/airavata/mft/controller/db/entities/TargetAgentEntity.java
+++ b/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/entities/TargetAgentEntity.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.airavata.mft.controller.db.entities;
+package org.apache.airavata.mft.api.db.entities;
 
 import javax.persistence.*;
 
diff --git a/controller/src/main/java/org/apache/airavata/mft/controller/db/entities/TargetAgentPK.java b/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/entities/TargetAgentPK.java
similarity index 96%
rename from controller/src/main/java/org/apache/airavata/mft/controller/db/entities/TargetAgentPK.java
rename to api/api-entities/src/main/java/org/apache/airavata/mft/api/db/entities/TargetAgentPK.java
index c0d7eb8..5d2aeb6 100644
--- a/controller/src/main/java/org/apache/airavata/mft/controller/db/entities/TargetAgentPK.java
+++ b/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/entities/TargetAgentPK.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.airavata.mft.controller.db.entities;
+package org.apache.airavata.mft.api.db.entities;
 
 import java.io.Serializable;
 import java.util.Objects;
diff --git a/controller/src/main/java/org/apache/airavata/mft/controller/db/entities/TransferEntity.java b/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/entities/TransferEntity.java
similarity index 99%
rename from controller/src/main/java/org/apache/airavata/mft/controller/db/entities/TransferEntity.java
rename to api/api-entities/src/main/java/org/apache/airavata/mft/api/db/entities/TransferEntity.java
index 64b12dd..5bcf6fa 100644
--- a/controller/src/main/java/org/apache/airavata/mft/controller/db/entities/TransferEntity.java
+++ b/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/entities/TransferEntity.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.airavata.mft.controller.db.entities;
+package org.apache.airavata.mft.api.db.entities;
 
 import javax.persistence.*;
 import java.util.Set;
diff --git a/controller/src/main/java/org/apache/airavata/mft/controller/db/entities/TransferExecutionEntity.java b/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/entities/TransferExecutionEntity.java
similarity index 97%
rename from controller/src/main/java/org/apache/airavata/mft/controller/db/entities/TransferExecutionEntity.java
rename to api/api-entities/src/main/java/org/apache/airavata/mft/api/db/entities/TransferExecutionEntity.java
index f95f5cd..4f79b38 100644
--- a/controller/src/main/java/org/apache/airavata/mft/controller/db/entities/TransferExecutionEntity.java
+++ b/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/entities/TransferExecutionEntity.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.airavata.mft.controller.db.entities;
+package org.apache.airavata.mft.api.db.entities;
 
 import javax.persistence.*;
 
diff --git a/controller/src/main/java/org/apache/airavata/mft/controller/db/entities/TransferStatusEntity.java b/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/entities/TransferStatusEntity.java
similarity index 90%
rename from controller/src/main/java/org/apache/airavata/mft/controller/db/entities/TransferStatusEntity.java
rename to api/api-entities/src/main/java/org/apache/airavata/mft/api/db/entities/TransferStatusEntity.java
index cd8cfe0..0cb70c6 100644
--- a/controller/src/main/java/org/apache/airavata/mft/controller/db/entities/TransferStatusEntity.java
+++ b/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/entities/TransferStatusEntity.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.airavata.mft.controller.db.entities;
+package org.apache.airavata.mft.api.db.entities;
 
 import javax.persistence.*;
 
@@ -31,7 +31,7 @@ public class TransferStatusEntity {
     private TransferEntity transfer;
 
     @Column(name = "STATE")
-    private String status;
+    private String state;
 
     @Column(name = "UPDATE_TIME")
     private long updateTimeMils;
@@ -57,12 +57,12 @@ public class TransferStatusEntity {
         return this;
     }
 
-    public String getStatus() {
-        return status;
+    public String getState() {
+        return state;
     }
 
-    public TransferStatusEntity setStatus(String status) {
-        this.status = status;
+    public TransferStatusEntity setState(String state) {
+        this.state = state;
         return this;
     }
 
diff --git a/controller/src/main/java/org/apache/airavata/mft/controller/db/repositories/TargetAgentRepository.java b/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/repositories/TargetAgentRepository.java
similarity index 84%
rename from controller/src/main/java/org/apache/airavata/mft/controller/db/repositories/TargetAgentRepository.java
rename to api/api-entities/src/main/java/org/apache/airavata/mft/api/db/repositories/TargetAgentRepository.java
index d7fa73e..4ed3d9d 100644
--- a/controller/src/main/java/org/apache/airavata/mft/controller/db/repositories/TargetAgentRepository.java
+++ b/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/repositories/TargetAgentRepository.java
@@ -15,10 +15,12 @@
  * limitations under the License.
  */
 
-package org.apache.airavata.mft.controller.db.repositories;
+package org.apache.airavata.mft.api.db.repositories;
 
-import org.apache.airavata.mft.controller.db.entities.TargetAgentEntity;
+import org.apache.airavata.mft.api.db.entities.TargetAgentEntity;
 import org.springframework.data.repository.CrudRepository;
+import org.springframework.stereotype.Repository;
 
+@Repository
 public interface TargetAgentRepository extends CrudRepository<TargetAgentEntity, String> {
 }
diff --git a/controller/src/main/java/org/apache/airavata/mft/controller/db/repositories/TransferRepository.java b/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/repositories/TransferRepository.java
similarity index 84%
rename from controller/src/main/java/org/apache/airavata/mft/controller/db/repositories/TransferRepository.java
rename to api/api-entities/src/main/java/org/apache/airavata/mft/api/db/repositories/TransferRepository.java
index bf3a704..e21d943 100644
--- a/controller/src/main/java/org/apache/airavata/mft/controller/db/repositories/TransferRepository.java
+++ b/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/repositories/TransferRepository.java
@@ -15,10 +15,12 @@
  * limitations under the License.
  */
 
-package org.apache.airavata.mft.controller.db.repositories;
+package org.apache.airavata.mft.api.db.repositories;
 
-import org.apache.airavata.mft.controller.db.entities.TransferEntity;
+import org.apache.airavata.mft.api.db.entities.TransferEntity;
 import org.springframework.data.repository.CrudRepository;
+import org.springframework.stereotype.Repository;
 
+@Repository
 public interface TransferRepository extends CrudRepository<TransferEntity, String> {
 }
diff --git a/controller/src/main/java/org/apache/airavata/mft/controller/db/repositories/TransferStatusRepository.java b/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/repositories/TransferStatusRepository.java
similarity index 66%
copy from controller/src/main/java/org/apache/airavata/mft/controller/db/repositories/TransferStatusRepository.java
copy to api/api-entities/src/main/java/org/apache/airavata/mft/api/db/repositories/TransferStatusRepository.java
index 0f03d8e..f801e0c 100644
--- a/controller/src/main/java/org/apache/airavata/mft/controller/db/repositories/TransferStatusRepository.java
+++ b/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/repositories/TransferStatusRepository.java
@@ -15,10 +15,19 @@
  * limitations under the License.
  */
 
-package org.apache.airavata.mft.controller.db.repositories;
+package org.apache.airavata.mft.api.db.repositories;
 
-import org.apache.airavata.mft.controller.db.entities.TransferStatusEntity;
+import org.apache.airavata.mft.api.db.entities.TransferStatusEntity;
+import org.springframework.data.jpa.repository.Query;
 import org.springframework.data.repository.CrudRepository;
+import org.springframework.stereotype.Repository;
 
+import java.util.List;
+import java.util.Optional;
+
+@Repository
 public interface TransferStatusRepository extends CrudRepository<TransferStatusEntity, Integer> {
+
+    @Query("SELECT ts from TransferStatusEntity ts WHERE ts.transfer.transferId = ?1 ORDER BY ts.updateTimeMils DESC")
+    public List<TransferStatusEntity> getByTransferId(String transferId);
 }
diff --git a/api/client/pom.xml b/api/client/pom.xml
new file mode 100644
index 0000000..d54623c
--- /dev/null
+++ b/api/client/pom.xml
@@ -0,0 +1,43 @@
+<?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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>mft-api</artifactId>
+        <groupId>org.apache.airavata</groupId>
+        <version>0.01-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>mft-api-client</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.airavata</groupId>
+            <artifactId>mft-api-stub</artifactId>
+            <version>0.01-SNAPSHOT</version>
+        </dependency>
+    </dependencies>
+
+</project>
\ No newline at end of file
diff --git a/api/client/src/main/java/org/apache/airavata/mft/api/client/MFTApiClient.java b/api/client/src/main/java/org/apache/airavata/mft/api/client/MFTApiClient.java
new file mode 100644
index 0000000..82bfcbb
--- /dev/null
+++ b/api/client/src/main/java/org/apache/airavata/mft/api/client/MFTApiClient.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.airavata.mft.api.client;
+
+import io.grpc.ManagedChannel;
+import io.grpc.ManagedChannelBuilder;
+import org.apache.airavata.mft.api.service.*;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+public class MFTApiClient {
+    private static Map<String, Map<Integer, MFTApiServiceGrpc.MFTApiServiceBlockingStub>> stubCache = new ConcurrentHashMap<>();
+
+    public static MFTApiServiceGrpc.MFTApiServiceBlockingStub buildClient(String hostName, int port) {
+
+        if (stubCache.containsKey(hostName)) {
+            if (stubCache.get(hostName).containsKey(port)) {
+                return stubCache.get(hostName).get(port);
+            }
+        }
+
+        ManagedChannel channel = ManagedChannelBuilder.forAddress(hostName, port).usePlaintext().build();
+        MFTApiServiceGrpc.MFTApiServiceBlockingStub stub = MFTApiServiceGrpc.newBlockingStub(channel);
+        stubCache.put(hostName, Collections.singletonMap(port, stub));
+        return stub;
+    }
+}
diff --git a/api/pom.xml b/api/pom.xml
new file mode 100644
index 0000000..f7eb249
--- /dev/null
+++ b/api/pom.xml
@@ -0,0 +1,70 @@
+<?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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>airavata-mft</artifactId>
+        <groupId>org.apache.airavata</groupId>
+        <version>0.01-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>mft-api</artifactId>
+    <packaging>pom</packaging>
+    <modules>
+        <module>stub</module>
+        <module>service</module>
+        <module>client</module>
+        <module>api-entities</module>
+    </modules>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.google.protobuf</groupId>
+            <artifactId>protobuf-java</artifactId>
+            <version>${protobuf.java}</version>
+        </dependency>
+        <dependency>
+            <groupId>io.github.lognet</groupId>
+            <artifactId>grpc-spring-boot-starter</artifactId>
+            <version>${grpc.spring.boot}</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.springframework.boot</groupId>
+                    <artifactId>spring-boot-starter</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-jpa</artifactId>
+            <version>${spring.boot.data.jpa}</version>
+        </dependency>
+        <dependency>
+            <groupId>net.sf.dozer</groupId>
+            <artifactId>dozer</artifactId>
+            <version>${dozer}</version>
+        </dependency>
+    </dependencies>
+</project>
\ No newline at end of file
diff --git a/api/service/pom.xml b/api/service/pom.xml
new file mode 100644
index 0000000..deb9e23
--- /dev/null
+++ b/api/service/pom.xml
@@ -0,0 +1,65 @@
+<?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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>mft-api</artifactId>
+        <groupId>org.apache.airavata</groupId>
+        <version>0.01-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>mft-api-service</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.airavata</groupId>
+            <artifactId>mft-api-stub</artifactId>
+            <version>0.01-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>com.h2database</groupId>
+            <artifactId>h2</artifactId>
+            <version>${h2}</version>
+            <scope>runtime</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.mariadb.jdbc</groupId>
+            <artifactId>mariadb-java-client</artifactId>
+            <version>2.5.1</version>
+            <scope>runtime</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.airavata</groupId>
+            <artifactId>mft-api-entities</artifactId>
+            <version>0.01-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.airavata</groupId>
+            <artifactId>mft-admin</artifactId>
+            <version>0.01-SNAPSHOT</version>
+        </dependency>
+    </dependencies>
+
+</project>
\ No newline at end of file
diff --git a/controller/src/main/java/org/apache/airavata/mft/controller/db/repositories/TransferStatusRepository.java b/api/service/src/main/java/org/apache/airavata/mft/api/ApiServiceApplication.java
similarity index 63%
copy from controller/src/main/java/org/apache/airavata/mft/controller/db/repositories/TransferStatusRepository.java
copy to api/service/src/main/java/org/apache/airavata/mft/api/ApiServiceApplication.java
index 0f03d8e..94f78bd 100644
--- a/controller/src/main/java/org/apache/airavata/mft/controller/db/repositories/TransferStatusRepository.java
+++ b/api/service/src/main/java/org/apache/airavata/mft/api/ApiServiceApplication.java
@@ -15,10 +15,16 @@
  * limitations under the License.
  */
 
-package org.apache.airavata.mft.controller.db.repositories;
+package org.apache.airavata.mft.api;
 
-import org.apache.airavata.mft.controller.db.entities.TransferStatusEntity;
-import org.springframework.data.repository.CrudRepository;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ComponentScan;
 
-public interface TransferStatusRepository extends CrudRepository<TransferStatusEntity, Integer> {
+@SpringBootApplication
+@ComponentScan(basePackages = {"org.apache.airavata.mft"})
+public class ApiServiceApplication {
+    public static void main(String args[]) {
+        SpringApplication.run(ApiServiceApplication.class, args);
+    }
 }
diff --git a/api/service/src/main/java/org/apache/airavata/mft/api/AppConfig.java b/api/service/src/main/java/org/apache/airavata/mft/api/AppConfig.java
new file mode 100644
index 0000000..964ccc1
--- /dev/null
+++ b/api/service/src/main/java/org/apache/airavata/mft/api/AppConfig.java
@@ -0,0 +1,48 @@
+/*
+ * 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.airavata.mft.api;
+
+import org.apache.airavata.mft.admin.MFTAdmin;
+import org.apache.airavata.mft.admin.models.TransferRequest;
+import org.apache.airavata.mft.api.service.TransferApiRequest;
+import org.dozer.DozerBeanMapper;
+import org.dozer.loader.api.BeanMappingBuilder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class AppConfig {
+    @Bean
+    public MFTAdmin mftAdmin() {
+        return new MFTAdmin();
+    }
+
+    @Bean
+    public DozerBeanMapper dozerBeanMapper() {
+        DozerBeanMapper mapper = new DozerBeanMapper();
+        BeanMappingBuilder mappingBuilder = new BeanMappingBuilder() {
+            @Override
+            protected void configure() {
+                mapping(TransferApiRequest.class, TransferRequest.class).exclude("targetAgents");
+            }
+        };
+
+        mapper.addMapping(mappingBuilder);
+        return mapper;
+    }
+}
diff --git a/api/service/src/main/java/org/apache/airavata/mft/api/handler/MFTApiHandler.java b/api/service/src/main/java/org/apache/airavata/mft/api/handler/MFTApiHandler.java
new file mode 100644
index 0000000..acf5ff2
--- /dev/null
+++ b/api/service/src/main/java/org/apache/airavata/mft/api/handler/MFTApiHandler.java
@@ -0,0 +1,94 @@
+/*
+ * 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.airavata.mft.api.handler;
+
+import io.grpc.stub.StreamObserver;
+import org.apache.airavata.mft.admin.MFTAdmin;
+import org.apache.airavata.mft.admin.models.TransferRequest;
+import org.apache.airavata.mft.api.service.*;
+import org.apache.airavata.mft.api.db.entities.TransferStatusEntity;
+import org.apache.airavata.mft.api.db.repositories.TransferStatusRepository;
+import org.dozer.DozerBeanMapper;
+import org.lognet.springboot.grpc.GRpcService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.List;
+import java.util.Optional;
+
+@GRpcService
+public class MFTApiHandler extends MFTApiServiceGrpc.MFTApiServiceImplBase {
+
+    private static final Logger logger = LoggerFactory.getLogger(MFTApiHandler.class);
+
+    @Autowired
+    private TransferStatusRepository statusRepository;
+
+    @Autowired
+    private MFTAdmin mftAdmin;
+
+    @Autowired
+    private DozerBeanMapper dozerBeanMapper;
+
+    @Override
+    public void submitTransfer(TransferApiRequest request, StreamObserver<TransferApiResponse> responseObserver) {
+        try {
+            TransferRequest transferRequest = dozerBeanMapper.map(request, TransferRequest.class);
+            Optional.ofNullable(request.getTargetAgentsMap()).ifPresent(transferRequest::setTargetAgents); // Custom mapping
+
+            String transferId = mftAdmin.submitTransfer(transferRequest);
+            logger.info("Submitted the transfer request {}", transferId);
+            responseObserver.onNext(TransferApiResponse.newBuilder().setTransferId(transferId).build());
+            responseObserver.onCompleted();
+        } catch (Exception e) {
+            logger.error("Error in submitting transfer request", e);
+            responseObserver.onError(new Exception("Failed to submit transfer", e));
+        }
+    }
+
+    @Override
+    public void getTransferStates(TransferStateApiRequest request, StreamObserver<TransferStateApiResponse> responseObserver) {
+        try {
+            List<TransferStatusEntity> states = statusRepository.getByTransferId(request.getTransferId());
+            states.forEach(st -> {
+                TransferStateApiResponse s = dozerBeanMapper.map(st, TransferStateApiResponse.newBuilder().getClass()).build();
+                responseObserver.onNext(s);
+            });
+            responseObserver.onCompleted();
+        } catch (Exception e) {
+            logger.error("Error in fetching transfer states", e);
+            responseObserver.onError(new Exception("Failed to retrieve transfer states", e));
+        }
+    }
+
+    @Override
+    public void getTransferState(TransferStateApiRequest request, StreamObserver<TransferStateApiResponse> responseObserver) {
+        try {
+            List<TransferStatusEntity> states = statusRepository.getByTransferId(request.getTransferId());
+            states.stream().findFirst().ifPresent(st -> {
+                TransferStateApiResponse s = dozerBeanMapper.map(st, TransferStateApiResponse.newBuilder().getClass()).build();
+                responseObserver.onNext(s);
+            });
+            responseObserver.onCompleted();
+        } catch (Exception e) {
+            logger.error("Error in fetching transfer state", e);
+            responseObserver.onError(new Exception("Failed to retrieve transfer state", e));
+        }
+    }
+}
diff --git a/controller/src/main/resources/application.properties b/api/service/src/main/resources/application.properties
similarity index 74%
copy from controller/src/main/resources/application.properties
copy to api/service/src/main/resources/application.properties
index a9fd83f..cea44d3 100644
--- a/controller/src/main/resources/application.properties
+++ b/api/service/src/main/resources/application.properties
@@ -13,4 +13,12 @@
 # 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.
-#
\ No newline at end of file
+#
+
+server.port=8088
+grpc.port=7004
+spring.datasource.url=jdbc:mariadb://localhost:3306/controllerdb
+spring.datasource.username=root
+spring.datasource.password=root
+spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
+spring.jpa.hibernate.ddl-auto=create-drop
\ No newline at end of file
diff --git a/api/service/src/main/resources/logback.xml b/api/service/src/main/resources/logback.xml
new file mode 100644
index 0000000..a1e67fe
--- /dev/null
+++ b/api/service/src/main/resources/logback.xml
@@ -0,0 +1,54 @@
+<?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.
+
+-->
+<configuration>
+
+    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+            <pattern>%d [%t] %-5p %c{30} %m [%X]%n</pattern>
+        </encoder>
+    </appender>
+
+    <appender name="LOGFILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <File>../logs/airavata.log</File>
+        <Append>true</Append>
+        <encoder>
+            <pattern>%d [%t] %-5p %c{30} %m [%X]%n</pattern>
+        </encoder>
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <fileNamePattern>../logs/airavata.log.%d{yyyy-MM-dd}</fileNamePattern>
+            <maxHistory>30</maxHistory>
+            <totalSizeCap>1GB</totalSizeCap>
+        </rollingPolicy>
+    </appender>
+
+    <logger name="ch.qos.logback" level="WARN"/>
+    <logger name="org.apache.helix" level="WARN"/>
+    <logger name="org.apache.zookeeper" level="ERROR"/>
+    <logger name="org.apache.airavata" level="INFO"/>
+    <logger name="org.hibernate" level="ERROR"/>
+    <logger name="net.schmizz.sshj" level="WARN"/>
+    <root level="INFO">
+        <appender-ref ref="CONSOLE"/>
+        <appender-ref ref="LOGFILE"/>
+    </root>
+</configuration>
diff --git a/api/stub/pom.xml b/api/stub/pom.xml
new file mode 100644
index 0000000..1f1c125
--- /dev/null
+++ b/api/stub/pom.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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>mft-api</artifactId>
+        <groupId>org.apache.airavata</groupId>
+        <version>0.01-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>mft-api-stub</artifactId>
+
+    <build>
+        <extensions>
+            <extension>
+                <groupId>kr.motd.maven</groupId>
+                <artifactId>os-maven-plugin</artifactId>
+                <version>${os.maven.plugin}</version>
+            </extension>
+        </extensions>
+        <plugins>
+            <plugin>
+                <groupId>org.xolstice.maven.plugins</groupId>
+                <artifactId>protobuf-maven-plugin</artifactId>
+                <version>${protobuf.maven.plugin}</version>
+                <configuration>
+                    <protocArtifact>com.google.protobuf:protoc:3.0.2:exe:${os.detected.classifier}</protocArtifact>
+                    <pluginId>grpc-java</pluginId>
+                    <pluginArtifact>io.grpc:protoc-gen-grpc-java:1.0.1:exe:${os.detected.classifier}</pluginArtifact>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>compile</goal>
+                            <goal>compile-custom</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>
\ No newline at end of file
diff --git a/api/stub/src/main/proto/MFTApi.proto b/api/stub/src/main/proto/MFTApi.proto
new file mode 100644
index 0000000..440c3d3
--- /dev/null
+++ b/api/stub/src/main/proto/MFTApi.proto
@@ -0,0 +1,57 @@
+syntax = "proto3";
+
+option java_multiple_files = true;
+package org.apache.airavata.mft.api.service;
+
+import "google/api/annotations.proto";
+import "google/protobuf/empty.proto";
+
+message TransferApiRequest {
+    string sourceId = 1;
+    string sourceType = 2;
+    string sourceToken = 3;
+    string sourceResourceBackend = 4;
+    string sourceCredentialBackend = 5;
+    string destinationId = 6;
+    string destinationType = 7;
+    string destinationToken = 8;
+    string destResourceBackend = 9;
+    string destCredentialBackend = 10;
+    bool affinityTransfer = 11;
+    map<string, int32> targetAgents = 12;
+}
+
+message TransferApiResponse {
+    string transferId = 1;
+}
+
+message TransferStateApiRequest {
+    string transferId = 1;
+}
+
+message TransferStateApiResponse {
+    string state = 1;
+    int64 updateTimeMils = 2;
+    double percentage = 3;
+}
+
+service  MFTApiService {
+
+    rpc submitTransfer(TransferApiRequest) returns (TransferApiResponse) {
+        option (google.api.http) = {
+           post: "/v1.0/api/transfer"
+        };
+    }
+
+    rpc getTransferStates(TransferStateApiRequest) returns (stream TransferStateApiResponse) {
+        option (google.api.http) = {
+           get: "/v1.0/api/transfer/states"
+        };
+    }
+
+    rpc getTransferState(TransferStateApiRequest) returns (TransferStateApiResponse) {
+        option (google.api.http) = {
+           get: "/v1.0/api/transfer/state"
+        };
+    }
+}
\ No newline at end of file
diff --git a/controller/pom.xml b/controller/pom.xml
index 81777b2..d1a454c 100644
--- a/controller/pom.xml
+++ b/controller/pom.xml
@@ -39,6 +39,11 @@
             <version>0.01-SNAPSHOT</version>
         </dependency>
         <dependency>
+            <groupId>org.apache.airavata</groupId>
+            <artifactId>mft-api-entities</artifactId>
+            <version>0.01-SNAPSHOT</version>
+        </dependency>
+        <dependency>
             <groupId>com.orbitz.consul</groupId>
             <artifactId>consul-client</artifactId>
             <version>${consul.client}</version>
@@ -71,6 +76,12 @@
             <scope>runtime</scope>
         </dependency>
         <dependency>
+            <groupId>org.mariadb.jdbc</groupId>
+            <artifactId>mariadb-java-client</artifactId>
+            <version>2.5.1</version>
+            <scope>runtime</scope>
+        </dependency>
+        <dependency>
             <groupId>net.sf.dozer</groupId>
             <artifactId>dozer</artifactId>
             <version>${dozer}</version>
diff --git a/controller/src/main/java/org/apache/airavata/mft/controller/db/repositories/TransferStatusRepository.java b/controller/src/main/java/org/apache/airavata/mft/controller/AppConfig.java
similarity index 73%
rename from controller/src/main/java/org/apache/airavata/mft/controller/db/repositories/TransferStatusRepository.java
rename to controller/src/main/java/org/apache/airavata/mft/controller/AppConfig.java
index 0f03d8e..c9fdbd0 100644
--- a/controller/src/main/java/org/apache/airavata/mft/controller/db/repositories/TransferStatusRepository.java
+++ b/controller/src/main/java/org/apache/airavata/mft/controller/AppConfig.java
@@ -15,10 +15,10 @@
  * limitations under the License.
  */
 
-package org.apache.airavata.mft.controller.db.repositories;
+package org.apache.airavata.mft.controller;
 
-import org.apache.airavata.mft.controller.db.entities.TransferStatusEntity;
-import org.springframework.data.repository.CrudRepository;
+import org.springframework.context.annotation.Configuration;
 
-public interface TransferStatusRepository extends CrudRepository<TransferStatusEntity, Integer> {
+@Configuration
+public class AppConfig {
 }
diff --git a/controller/src/main/java/org/apache/airavata/mft/controller/MFTController.java b/controller/src/main/java/org/apache/airavata/mft/controller/MFTController.java
index 2c2fe49..1a63ac4 100644
--- a/controller/src/main/java/org/apache/airavata/mft/controller/MFTController.java
+++ b/controller/src/main/java/org/apache/airavata/mft/controller/MFTController.java
@@ -26,11 +26,11 @@ import com.orbitz.consul.model.kv.Value;
 import org.apache.airavata.mft.admin.MFTAdmin;
 import org.apache.airavata.mft.admin.models.TransferCommand;
 import org.apache.airavata.mft.admin.models.TransferState;
-import org.apache.airavata.mft.controller.db.entities.TransferEntity;
-import org.apache.airavata.mft.controller.db.entities.TransferStatusEntity;
-import org.apache.airavata.mft.controller.db.repositories.TransferRepository;
+import org.apache.airavata.mft.api.db.entities.TransferEntity;
+import org.apache.airavata.mft.api.db.entities.TransferStatusEntity;
+import org.apache.airavata.mft.api.db.repositories.TransferRepository;
 import org.apache.airavata.mft.admin.models.TransferRequest;
-import org.apache.airavata.mft.controller.db.repositories.TransferStatusRepository;
+import org.apache.airavata.mft.api.db.repositories.TransferStatusRepository;
 import org.dozer.DozerBeanMapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -38,15 +38,20 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.CommandLineRunner;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.domain.EntityScan;
+import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.PropertySource;
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
 
-import java.io.IOException;
 import java.util.List;
 import java.util.Optional;
 import java.util.concurrent.Semaphore;
 
 @PropertySource("classpath:application.properties")
 @SpringBootApplication()
+@ComponentScan(basePackages = {"org.apache.airavata.mft"})
+@EnableJpaRepositories("org.apache.airavata.mft.api.db.repositories")
+@EntityScan("org.apache.airavata.mft.api.db.entities")
 public class MFTController implements CommandLineRunner {
 
     private static final Logger logger = LoggerFactory.getLogger(MFTController.class);
@@ -166,7 +171,7 @@ public class MFTController implements CommandLineRunner {
                         if (transferEntity.isPresent()) {
                             TransferStatusEntity ety = new TransferStatusEntity()
                                     .setPercentage(transferState.getPercentage())
-                                    .setStatus(transferState.getState())
+                                    .setState(transferState.getState())
                                     .setUpdateTimeMils(transferState.getUpdateTimeMils())
                                     .setTransfer(transferEntity.get());
                             statusRepository.save(ety);
diff --git a/controller/src/main/resources/application.properties b/controller/src/main/resources/application.properties
index a9fd83f..101a8fe 100644
--- a/controller/src/main/resources/application.properties
+++ b/controller/src/main/resources/application.properties
@@ -13,4 +13,10 @@
 # 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.
-#
\ No newline at end of file
+#
+
+spring.datasource.url=jdbc:mariadb://localhost:3306/controllerdb
+spring.datasource.username=root
+spring.datasource.password=root
+spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
+spring.jpa.hibernate.ddl-auto=create-drop
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 26f0bd8..e1dfe0a 100755
--- a/pom.xml
+++ b/pom.xml
@@ -47,6 +47,7 @@
         <module>services</module>
         <module>admin</module>
         <module>controller</module>
+        <module>api</module>
     </modules>
 
     <url>http://airavata.apache.org/</url>