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 2019/12/11 22:02:30 UTC
[airavata-mft] branch master updated: Framework for Resource Service
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 35c570e Framework for Resource Service
35c570e is described below
commit 35c570ee2b2ab4d496aa144351bb221fa85c294c
Author: Dimuthu Wannipurage <di...@gmail.com>
AuthorDate: Wed Dec 11 17:02:15 2019 -0500
Framework for Resource Service
---
pom.xml | 15 ++++++++
services/pom.xml | 19 ++++++++++
services/resource-service/client/pom.xml | 22 +++++++++++
.../mft/resource/client/ResourceServiceClient.java | 12 ++++++
services/resource-service/pom.xml | 33 ++++++++++++++++
services/resource-service/server/pom.xml | 21 +++++++++++
.../server/ResourceServiceApplication.java | 11 ++++++
.../server/handler/ResourceServiceHandler.java | 18 +++++++++
.../src/main/resources/application.properties | 2 +
services/resource-service/stub/pom.xml | 44 ++++++++++++++++++++++
.../stub/src/main/proto/ResourceService.proto | 24 ++++++++++++
11 files changed, 221 insertions(+)
diff --git a/pom.xml b/pom.xml
index 30a5b1d..821b297 100755
--- a/pom.xml
+++ b/pom.xml
@@ -44,6 +44,7 @@
<module>core</module>
<module>transport</module>
<module>agent</module>
+ <module>services</module>
</modules>
<url>http://airavata.apache.org/</url>
@@ -94,4 +95,18 @@
</plugins>
</build>
+ <dependencies>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>javax.annotation-api</artifactId>
+ <version>${javax.annotation}</version>
+ </dependency>
+ </dependencies>
+
+ <properties>
+ <protobuf.maven.plugin>0.5.1</protobuf.maven.plugin>
+ <os.maven.plugin>1.5.0.Final</os.maven.plugin>
+ <javax.annotation>1.3.2</javax.annotation>
+ </properties>
+
</project>
\ No newline at end of file
diff --git a/services/pom.xml b/services/pom.xml
new file mode 100644
index 0000000..625641f
--- /dev/null
+++ b/services/pom.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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>
+ <packaging>pom</packaging>
+ <modules>
+ <module>resource-service</module>
+ </modules>
+
+ <artifactId>mft-services</artifactId>
+
+
+</project>
\ No newline at end of file
diff --git a/services/resource-service/client/pom.xml b/services/resource-service/client/pom.xml
new file mode 100644
index 0000000..280bc45
--- /dev/null
+++ b/services/resource-service/client/pom.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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-resource-service</artifactId>
+ <groupId>org.apache.airavata</groupId>
+ <version>0.01-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>mft-resource-service-client</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>mft-resource-service-stub</artifactId>
+ <version>0.01-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
diff --git a/services/resource-service/client/src/main/java/org/apache/airavata/mft/resource/client/ResourceServiceClient.java b/services/resource-service/client/src/main/java/org/apache/airavata/mft/resource/client/ResourceServiceClient.java
new file mode 100644
index 0000000..8ea1d5c
--- /dev/null
+++ b/services/resource-service/client/src/main/java/org/apache/airavata/mft/resource/client/ResourceServiceClient.java
@@ -0,0 +1,12 @@
+package org.apache.airavata.mft.resource.client;
+
+import io.grpc.ManagedChannel;
+import io.grpc.ManagedChannelBuilder;
+import org.apache.airavata.mft.resource.service.ResourceServiceGrpc;
+
+public class ResourceServiceClient {
+ public static ResourceServiceGrpc.ResourceServiceBlockingStub buildClient(String hostName, int port) {
+ ManagedChannel channel = ManagedChannelBuilder.forAddress(hostName, port).usePlaintext().build();
+ return ResourceServiceGrpc.newBlockingStub(channel);
+ }
+}
diff --git a/services/resource-service/pom.xml b/services/resource-service/pom.xml
new file mode 100644
index 0000000..0299549
--- /dev/null
+++ b/services/resource-service/pom.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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-services</artifactId>
+ <groupId>org.apache.airavata</groupId>
+ <version>0.01-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>mft-resource-service</artifactId>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>stub</module>
+ <module>server</module>
+ <module>client</module>
+ </modules>
+ <dependencies>
+ <dependency>
+ <groupId>com.google.protobuf</groupId>
+ <artifactId>protobuf-java</artifactId>
+ <version>3.4.0</version>
+ </dependency>
+ <dependency>
+ <groupId>io.github.lognet</groupId>
+ <artifactId>grpc-spring-boot-starter</artifactId>
+ <version>3.5.0</version>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
diff --git a/services/resource-service/server/pom.xml b/services/resource-service/server/pom.xml
new file mode 100644
index 0000000..c98caf8
--- /dev/null
+++ b/services/resource-service/server/pom.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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-resource-service</artifactId>
+ <groupId>org.apache.airavata</groupId>
+ <version>0.01-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>mft-resource-service-server</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>mft-resource-service-stub</artifactId>
+ <version>0.01-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
diff --git a/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/ResourceServiceApplication.java b/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/ResourceServiceApplication.java
new file mode 100644
index 0000000..91810b7
--- /dev/null
+++ b/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/ResourceServiceApplication.java
@@ -0,0 +1,11 @@
+package org.apache.airavata.mft.resource.server;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class ResourceServiceApplication {
+ public static void main(String args[]) {
+ SpringApplication.run(ResourceServiceApplication.class, args);
+ }
+}
diff --git a/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/handler/ResourceServiceHandler.java b/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/handler/ResourceServiceHandler.java
new file mode 100644
index 0000000..6eea77a
--- /dev/null
+++ b/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/handler/ResourceServiceHandler.java
@@ -0,0 +1,18 @@
+package org.apache.airavata.mft.resource.server.handler;
+
+import io.grpc.stub.StreamObserver;
+import org.apache.airavata.mft.resource.service.ResourceServiceGrpc;
+import org.apache.airavata.mft.resource.service.SCPResource;
+import org.apache.airavata.mft.resource.service.SCPResourceRequest;
+import org.lognet.springboot.grpc.GRpcService;
+
+@GRpcService
+public class ResourceServiceHandler extends ResourceServiceGrpc.ResourceServiceImplBase {
+
+ @Override
+ public void getSCPResource(SCPResourceRequest request, StreamObserver<SCPResource> responseObserver) {
+ SCPResource.Builder resourceBuilder = SCPResource.newBuilder().setHost("localhost").setPort(22);
+ responseObserver.onNext(resourceBuilder.build());
+ responseObserver.onCompleted();
+ }
+}
diff --git a/services/resource-service/server/src/main/resources/application.properties b/services/resource-service/server/src/main/resources/application.properties
new file mode 100644
index 0000000..52c5b6c
--- /dev/null
+++ b/services/resource-service/server/src/main/resources/application.properties
@@ -0,0 +1,2 @@
+server.port=8080
+grpc.port=7002
\ No newline at end of file
diff --git a/services/resource-service/stub/pom.xml b/services/resource-service/stub/pom.xml
new file mode 100644
index 0000000..ee6b58b
--- /dev/null
+++ b/services/resource-service/stub/pom.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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-resource-service</artifactId>
+ <groupId>org.apache.airavata</groupId>
+ <version>0.01-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>mft-resource-service-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/services/resource-service/stub/src/main/proto/ResourceService.proto b/services/resource-service/stub/src/main/proto/ResourceService.proto
new file mode 100644
index 0000000..681a7c1
--- /dev/null
+++ b/services/resource-service/stub/src/main/proto/ResourceService.proto
@@ -0,0 +1,24 @@
+syntax = "proto3";
+
+option java_multiple_files = true;
+package org.apache.airavata.mft.resource.service;
+
+import "google/api/annotations.proto";
+
+message SCPResource {
+ string resourceId = 1;
+ string host = 2;
+ int32 port = 3;
+}
+
+message SCPResourceRequest {
+ string resourceId = 1;
+}
+
+service ResourceService {
+ rpc getSCPResource (SCPResourceRequest) returns (SCPResource) {
+ option (google.api.http) = {
+ get: "/v1.0/resource/scp"
+ };
+ }
+}
\ No newline at end of file