You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wayang.apache.org by rp...@apache.org on 2021/05/07 16:17:23 UTC

[incubator-wayang] branch debugger-sidecar updated: [WAYANG-30] Web Service local cluster demo execution

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

rpardomeza pushed a commit to branch debugger-sidecar
in repository https://gitbox.apache.org/repos/asf/incubator-wayang.git


The following commit(s) were added to refs/heads/debugger-sidecar by this push:
     new 9b93f92  [WAYANG-30] Web Service local cluster demo execution
9b93f92 is described below

commit 9b93f92d7a6c05feff7627e3370c0c6647075d1a
Author: rodrigopardomeza <ro...@gmail.com>
AuthorDate: Fri May 7 12:17:00 2021 -0400

    [WAYANG-30] Web Service local cluster demo execution
---
 .../wayang-hackit/wayang-hackit-sidecar/pom.xml    | 11 ++++
 .../hackit/sidecar/webservice/WebService.java      | 60 ++++++++++++++++++++++
 .../src/main/resources/application.properties      |  0
 3 files changed, 71 insertions(+)

diff --git a/wayang-plugins/wayang-hackit/wayang-hackit-sidecar/pom.xml b/wayang-plugins/wayang-hackit/wayang-hackit-sidecar/pom.xml
index 2eab5e2..6a6004d 100644
--- a/wayang-plugins/wayang-hackit/wayang-hackit-sidecar/pom.xml
+++ b/wayang-plugins/wayang-hackit/wayang-hackit-sidecar/pom.xml
@@ -51,6 +51,17 @@
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+            <version>RELEASE</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.flink</groupId>
+            <artifactId>flink-clients_2.11</artifactId>
+            <version>1.13.0</version>
+        </dependency>
     </dependencies>
 
     <build>
diff --git a/wayang-plugins/wayang-hackit/wayang-hackit-sidecar/src/main/java/org/apache/wayang/hackit/sidecar/webservice/WebService.java b/wayang-plugins/wayang-hackit/wayang-hackit-sidecar/src/main/java/org/apache/wayang/hackit/sidecar/webservice/WebService.java
index de50c11..850edee 100644
--- a/wayang-plugins/wayang-hackit/wayang-hackit-sidecar/src/main/java/org/apache/wayang/hackit/sidecar/webservice/WebService.java
+++ b/wayang-plugins/wayang-hackit/wayang-hackit-sidecar/src/main/java/org/apache/wayang/hackit/sidecar/webservice/WebService.java
@@ -1,4 +1,64 @@
 package org.apache.wayang.hackit.sidecar.webservice;
 
+import org.apache.flink.api.common.JobExecutionResult;
+import org.apache.flink.api.common.functions.FilterFunction;
+import org.apache.flink.api.java.DataSet;
+import org.apache.flink.api.java.ExecutionEnvironment;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/sidecar")
 public class WebService {
+
+    @GetMapping("/debug/request/get")
+    public HttpStatus requestGet(){
+
+        return HttpStatus.ACCEPTED;
+    }
+
+    @GetMapping("/debug/request/status")
+    public HttpStatus requestStatus(){
+
+        return HttpStatus.ACCEPTED;
+    }
+
+    @GetMapping("/debug/request/kill")
+    public HttpStatus requestKill(){
+
+        return HttpStatus.ACCEPTED;
+    }
+
+    @GetMapping("/debug/start")
+    public HttpStatus serviceStart(){
+
+        try {
+            // LocalEnvironment
+            ExecutionEnvironment env = ExecutionEnvironment.createLocalEnvironment();
+            DataSet<String> data = env.readTextFile("file:///Users/rodrigopardomeza/flink/count");
+
+            data
+                    .filter(new FilterFunction<String>() {
+                        public boolean filter(String value) {
+                            return value.startsWith("T");
+                        }
+                    })
+                    .writeAsText("file:///Users/rodrigopardomeza/flink/output");
+
+            JobExecutionResult res = env.execute();
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return HttpStatus.ACCEPTED;
+    }
+
+    @GetMapping("/debug/stop")
+    public HttpStatus serviceStop(){
+
+        return HttpStatus.ACCEPTED;
+    }
 }
diff --git a/wayang-plugins/wayang-hackit/wayang-hackit-sidecar/src/main/resources/application.properties b/wayang-plugins/wayang-hackit/wayang-hackit-sidecar/src/main/resources/application.properties
new file mode 100644
index 0000000..e69de29