You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ri...@apache.org on 2021/05/18 09:44:10 UTC

[incubator-streampipes] branch dev updated (d04a5b7 -> 80b3ef3)

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

riemer pushed a change to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git.


    from d04a5b7  [STREAMPIPES-74] Initiate multiple attempts to start pipelines upon startup
     new e3a10e8  [STREAMPIPES-360] Remove obsolete tests
     new 80b3ef3  [STREAMPIPES-360] Minor improvements in WorkerRestClient

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../master/management/WorkerRestClient.java        | 33 +---------------------
 .../master/management/WorkerRestClientTest.java    | 19 -------------
 2 files changed, 1 insertion(+), 51 deletions(-)

[incubator-streampipes] 01/02: [STREAMPIPES-360] Remove obsolete tests

Posted by ri...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

riemer pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git

commit e3a10e8cd9568260013eaca090fce055db55287d
Author: Dominik Riemer <ri...@fzi.de>
AuthorDate: Tue May 18 11:42:23 2021 +0200

    [STREAMPIPES-360] Remove obsolete tests
---
 .../master/management/WorkerRestClientTest.java       | 19 -------------------
 1 file changed, 19 deletions(-)

diff --git a/streampipes-connect-container-master/src/test/java/org/apache/streampipes/connect/container/master/management/WorkerRestClientTest.java b/streampipes-connect-container-master/src/test/java/org/apache/streampipes/connect/container/master/management/WorkerRestClientTest.java
index e87f012..5999b60 100644
--- a/streampipes-connect-container-master/src/test/java/org/apache/streampipes/connect/container/master/management/WorkerRestClientTest.java
+++ b/streampipes-connect-container-master/src/test/java/org/apache/streampipes/connect/container/master/management/WorkerRestClientTest.java
@@ -49,25 +49,6 @@ public class WorkerRestClientTest {
     }
 
     @Test
-    public void invokeStreamAdapterSuccess() throws Exception {
-        doNothing().when(WorkerRestClient.class, "startAdapter", anyString(), any());
-        when(WorkerRestClient.class, "invokeStreamAdapter", anyString(), any()).thenCallRealMethod();
-
-        WorkerRestClient.invokeStreamAdapter("", "");
-
-        verifyStatic(WorkerRestClient.class, times(1));
-        WorkerRestClient.startAdapter(eq("worker/stream/invoke"), any());
-    }
-
-    @Test(expected = AdapterException.class)
-    public void invokeStreamAdapterFail() throws Exception {
-        doThrow(new AdapterException()).when(WorkerRestClient.class, "startAdapter", anyString(), any());
-        when(WorkerRestClient.class, "invokeStreamAdapter", anyString(), any()).thenCallRealMethod();
-
-        WorkerRestClient.invokeStreamAdapter("", "");
-    }
-
-    @Test
     public void stopStreamAdapterSuccess() throws Exception {
 
         doNothing().when(WorkerRestClient.class, "stopAdapter", anyString(), any(), anyString());

[incubator-streampipes] 02/02: [STREAMPIPES-360] Minor improvements in WorkerRestClient

Posted by ri...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

riemer pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git

commit 80b3ef3d64ecb6d7fb30bd5f0dc630118c11b3ef
Author: Dominik Riemer <ri...@fzi.de>
AuthorDate: Tue May 18 11:43:45 2021 +0200

    [STREAMPIPES-360] Minor improvements in WorkerRestClient
---
 .../master/management/WorkerRestClient.java        | 33 +---------------------
 1 file changed, 1 insertion(+), 32 deletions(-)

diff --git a/streampipes-connect-container-master/src/main/java/org/apache/streampipes/connect/container/master/management/WorkerRestClient.java b/streampipes-connect-container-master/src/main/java/org/apache/streampipes/connect/container/master/management/WorkerRestClient.java
index 892725c..7f8d806 100644
--- a/streampipes-connect-container-master/src/main/java/org/apache/streampipes/connect/container/master/management/WorkerRestClient.java
+++ b/streampipes-connect-container-master/src/main/java/org/apache/streampipes/connect/container/master/management/WorkerRestClient.java
@@ -18,11 +18,8 @@
 
 package org.apache.streampipes.connect.container.master.management;
 
-import com.google.gson.Gson;
 import org.apache.http.client.fluent.Request;
 import org.apache.http.entity.ContentType;
-import org.apache.http.entity.mime.MultipartEntity;
-import org.apache.http.entity.mime.content.InputStreamBody;
 import org.apache.streampipes.connect.adapter.exception.AdapterException;
 import org.apache.streampipes.connect.container.master.util.AdapterEncryptionService;
 import org.apache.streampipes.model.connect.adapter.AdapterDescription;
@@ -32,7 +29,6 @@ import org.apache.streampipes.model.connect.grounding.ProtocolDescription;
 import org.apache.streampipes.model.runtime.RuntimeOptionsRequest;
 import org.apache.streampipes.model.runtime.RuntimeOptionsResponse;
 import org.apache.streampipes.model.util.Cloner;
-import org.apache.streampipes.serializers.json.GsonSerializer;
 import org.apache.streampipes.serializers.json.JacksonSerializer;
 import org.apache.streampipes.storage.api.IAdapterStorage;
 import org.apache.streampipes.storage.couchdb.impl.AdapterStorageImpl;
@@ -41,7 +37,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
 import java.net.URLEncoder;
 import java.nio.charset.StandardCharsets;
@@ -156,29 +151,6 @@ public class WorkerRestClient {
 
     }
 
-    public static String saveFileAtWorker(String baseUrl, InputStream inputStream, String fileName) throws AdapterException {
-        String url = baseUrl + "worker/file";
-        logger.info("Trying to start save file on endpoint: " + url);
-
-
-        MultipartEntity httpEntity = new MultipartEntity();
-        httpEntity.addPart("file_upload", new InputStreamBody(inputStream, fileName));
-
-        try {
-            String responseString = Request.Post(url)
-                    .body(httpEntity)
-                    .connectTimeout(1000)
-                    .socketTimeout(100000)
-                    .execute().returnContent().asString();
-
-            logger.info("File saved successfully at worker");
-            return responseString;
-        } catch (IOException e) {
-            e.printStackTrace();
-            throw new AdapterException("Could not save file on endpoint " + url);
-        }
-    }
-
     public static String getAdapterAssets(String baseUrl,  AdapterDescription ad) throws AdapterException {
         return getAssets(baseUrl + "worker/adapters", ad.getAppId());
     }
@@ -241,11 +213,10 @@ public class WorkerRestClient {
         logger.info("Trying to documentation from endpoint: " + url);
 
         try {
-            String responseString = Request.Get(url)
+            return Request.Get(url)
                     .connectTimeout(1000)
                     .socketTimeout(100000)
                     .execute().returnContent().asString();
-            return responseString;
         } catch (IOException e) {
             logger.error(e.getMessage());
             throw new AdapterException("Could not get documentation endpoint: " + url + " for adapter: " + appId);
@@ -281,8 +252,6 @@ public class WorkerRestClient {
     }
 
     private static void encryptAndUpdateAdapter(AdapterDescription adapter) {
-        Gson gson = GsonSerializer.getAdapterGsonBuilder().create();
-        System.out.println(gson.toJson(adapter));
         AdapterDescription encryptedDescription = new AdapterEncryptionService(new Cloner().adapterDescription(adapter)).encrypt();
         getAdapterStorage().updateAdapter(encryptedDescription);
     }