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 2022/10/23 21:43:16 UTC
[incubator-streampipes] 02/03: [STREAMPIPES-603] Show monitoring info for functions in pipeline overview
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 b299964bac3e2fb7a4aca85eef4d4096162266ab
Author: Dominik Riemer <do...@gmail.com>
AuthorDate: Sun Oct 23 23:41:07 2022 +0200
[STREAMPIPES-603] Show monitoring info for functions in pipeline overview
---
.../backend/StreamPipesResourceConfig.java | 1 +
.../streampipes/client/api/AbstractClientApi.java | 7 ++
.../apache/streampipes/client/api/AdminApi.java | 16 +++++
.../credentials/StreamPipesApiKeyCredentials.java | 4 +-
.../streampipes/client/http/DeleteRequest.java | 30 ++++++--
.../streampipes/client/http/HttpRequest.java | 2 +-
...ler.java => FunctionDeregistrationHandler.java} | 35 ++++------
.../function/FunctionRegistrationHandler.java | 37 ++++------
.../extensions/function/RegistrationHandler.java | 72 +++++++++++++++++++
.../function/StreamPipesFunctionHandler.java | 21 +++++-
.../model/function/FunctionDefinition.java | 63 +++++++++++++++++
.../streampipes/model/function/FunctionId.java | 22 ++++++
.../function/FunctionRegistrationService.java | 33 +++++----
.../monitoring/pipeline/ExtensionsLogProvider.java | 4 +-
.../rest/impl/AdapterMonitoringResource.java | 4 +-
.../streampipes/rest/impl/FunctionsResource.java | 70 +++++++++++++++++++
.../standalone/function/StreamPipesFunction.java | 5 +-
.../src/lib/apis/functions.service.ts | 53 ++++++++++++++
.../src/lib/model/gen/streampipes-model.ts | 46 +++++++++---
.../platform-services/src/public-api.ts | 1 +
.../adapter-details-logs.component.html | 17 ++---
.../adapter-details-metrics.component.html | 23 ++----
.../adapter-details-metrics.component.ts | 2 +-
ui/src/app/core-ui/core-ui.module.ts | 6 ++
.../simple-logs/simple-logs.component.html | 33 +++++++++
.../simple-logs/simple-logs.component.ts} | 15 +++-
.../simple-metrics/simple-metrics.component.html | 35 ++++++++++
.../simple-metrics/simple-metrics.component.ts} | 23 +++++-
.../abstract-function-details.directive.ts | 81 ++++++++++++++++++++++
.../functions-logs/functions-logs.component.html} | 22 ++----
.../functions-logs/functions-logs.component.ts | 35 +++++-----
.../functions-metrics.component.html} | 26 +++----
.../functions-metrics.component.ts | 28 ++++++++
.../functions-overview.component.html | 55 +++++++++++++++
.../functions-overview.component.scss} | 0
.../functions-overview.component.ts | 48 +++++++++++++
ui/src/app/pipelines/pipelines.component.html | 11 ++-
ui/src/app/pipelines/pipelines.component.ts | 56 +++++++++------
ui/src/app/pipelines/pipelines.module.ts | 16 ++++-
ui/src/app/pipelines/pipelines.routes.ts | 2 +-
40 files changed, 858 insertions(+), 202 deletions(-)
diff --git a/streampipes-backend/src/main/java/org/apache/streampipes/backend/StreamPipesResourceConfig.java b/streampipes-backend/src/main/java/org/apache/streampipes/backend/StreamPipesResourceConfig.java
index c55e23fc0..abab204ff 100644
--- a/streampipes-backend/src/main/java/org/apache/streampipes/backend/StreamPipesResourceConfig.java
+++ b/streampipes-backend/src/main/java/org/apache/streampipes/backend/StreamPipesResourceConfig.java
@@ -69,6 +69,7 @@ public class StreamPipesResourceConfig extends ResourceConfig {
register(EmailConfigurationResource.class);
register(EmailResource.class);
register(ExtensionsServiceEndpointResource.class);
+ register(FunctionsResource.class);
register(GeneralConfigurationResource.class);
register(GenericStorageResource.class);
register(LabelResource.class);
diff --git a/streampipes-client/src/main/java/org/apache/streampipes/client/api/AbstractClientApi.java b/streampipes-client/src/main/java/org/apache/streampipes/client/api/AbstractClientApi.java
index b2ccc12c6..0f5342757 100644
--- a/streampipes-client/src/main/java/org/apache/streampipes/client/api/AbstractClientApi.java
+++ b/streampipes-client/src/main/java/org/apache/streampipes/client/api/AbstractClientApi.java
@@ -48,6 +48,13 @@ public class AbstractClientApi {
return new DeleteRequest<>(clientConfig, apiPath, responseClass, serializer).executeRequest();
}
+ protected <T, O> O delete(StreamPipesApiPath apiPath,
+ T object,
+ Class<O> responseClass) {
+ Serializer<T, O, O> serializer = new ObjectSerializer<>();
+ return new DeleteRequest<>(clientConfig, apiPath, responseClass, serializer, object).executeRequest();
+ }
+
protected <T, O> O post(StreamPipesApiPath apiPath, T object, Class<O> responseClass) {
ObjectSerializer<T, O> serializer = new ObjectSerializer<>();
return new PostRequestWithPayloadResponse<>(clientConfig, apiPath, serializer, object, responseClass)
diff --git a/streampipes-client/src/main/java/org/apache/streampipes/client/api/AdminApi.java b/streampipes-client/src/main/java/org/apache/streampipes/client/api/AdminApi.java
index 5f42d3f98..2b47102fd 100644
--- a/streampipes-client/src/main/java/org/apache/streampipes/client/api/AdminApi.java
+++ b/streampipes-client/src/main/java/org/apache/streampipes/client/api/AdminApi.java
@@ -20,6 +20,8 @@ package org.apache.streampipes.client.api;
import org.apache.streampipes.client.model.StreamPipesClientConfig;
import org.apache.streampipes.client.util.StreamPipesApiPath;
import org.apache.streampipes.model.connect.adapter.AdapterDescription;
+import org.apache.streampipes.model.function.FunctionDefinition;
+import org.apache.streampipes.model.message.Message;
import java.util.List;
@@ -33,6 +35,14 @@ public class AdminApi extends AbstractClientApi {
post(getConnectPath(), adapters);
}
+ public void registerFunctions(List<FunctionDefinition> functions) {
+ post(getFunctionsPath(), functions);
+ }
+
+ public void deregisterFunctions(List<FunctionDefinition> functions) {
+ delete(getFunctionsPath(), functions, Message.class);
+ }
+
private StreamPipesApiPath getConnectPath() {
return StreamPipesApiPath
.fromBaseApiPath()
@@ -40,4 +50,10 @@ public class AdminApi extends AbstractClientApi {
.addToPath("master")
.addToPath("administration");
}
+
+ private StreamPipesApiPath getFunctionsPath() {
+ return StreamPipesApiPath
+ .fromBaseApiPath()
+ .addToPath("functions");
+ }
}
diff --git a/streampipes-client/src/main/java/org/apache/streampipes/client/credentials/StreamPipesApiKeyCredentials.java b/streampipes-client/src/main/java/org/apache/streampipes/client/credentials/StreamPipesApiKeyCredentials.java
index 34aecc911..39b73a9cb 100644
--- a/streampipes-client/src/main/java/org/apache/streampipes/client/credentials/StreamPipesApiKeyCredentials.java
+++ b/streampipes-client/src/main/java/org/apache/streampipes/client/credentials/StreamPipesApiKeyCredentials.java
@@ -25,8 +25,8 @@ import java.util.List;
public class StreamPipesApiKeyCredentials implements CredentialsProvider {
- private String username;
- private String apiKey;
+ private final String username;
+ private final String apiKey;
public StreamPipesApiKeyCredentials(String username,
String apiKey) {
diff --git a/streampipes-client/src/main/java/org/apache/streampipes/client/http/DeleteRequest.java b/streampipes-client/src/main/java/org/apache/streampipes/client/http/DeleteRequest.java
index 01c44bd25..d79072c2c 100644
--- a/streampipes-client/src/main/java/org/apache/streampipes/client/http/DeleteRequest.java
+++ b/streampipes-client/src/main/java/org/apache/streampipes/client/http/DeleteRequest.java
@@ -19,33 +19,51 @@ package org.apache.streampipes.client.http;
import org.apache.http.HttpEntity;
import org.apache.http.client.fluent.Request;
+import org.apache.http.entity.ContentType;
import org.apache.streampipes.client.model.StreamPipesClientConfig;
import org.apache.streampipes.client.serializer.Serializer;
import org.apache.streampipes.client.util.StreamPipesApiPath;
import java.io.IOException;
-public class DeleteRequest<DSO, DT> extends HttpRequest<Void, DSO, DT> {
+public class DeleteRequest<SO, DSO, DT> extends HttpRequest<SO, DSO, DT> {
- private Class<DSO> responseClass;
+ private final Class<DSO> responseClass;
+ private SO body;
public DeleteRequest(StreamPipesClientConfig clientConfig,
StreamPipesApiPath apiPath,
Class<DSO> responseClass,
- Serializer<Void, DSO, DT> serializer) {
+ Serializer<SO, DSO, DT> serializer) {
super(clientConfig, apiPath, serializer);
this.responseClass = responseClass;
}
+ public DeleteRequest(StreamPipesClientConfig clientConfig,
+ StreamPipesApiPath apiPath,
+ Class<DSO> responseClass,
+ Serializer<SO, DSO, DT> serializer,
+ SO body) {
+ super(clientConfig, apiPath, serializer);
+ this.responseClass = responseClass;
+ this.body = body;
+ }
+
@Override
- protected Request makeRequest(Serializer<Void, DSO, DT> serializer) {
- return Request
+ protected Request makeRequest(Serializer<SO, DSO, DT> serializer) {
+ var req = Request
.Delete(makeUrl())
.setHeaders(standardJsonHeaders());
+
+ if (this.body != null) {
+ req.bodyString(serializer.serialize(body), ContentType.APPLICATION_JSON);
+ }
+
+ return req;
}
@Override
- protected DT afterRequest(Serializer<Void, DSO, DT> serializer, HttpEntity entity) throws IOException {
+ protected DT afterRequest(Serializer<SO, DSO, DT> serializer, HttpEntity entity) throws IOException {
return serializer.deserialize(entityAsString(entity), responseClass);
}
}
diff --git a/streampipes-client/src/main/java/org/apache/streampipes/client/http/HttpRequest.java b/streampipes-client/src/main/java/org/apache/streampipes/client/http/HttpRequest.java
index cd5d17807..d1b902dc5 100644
--- a/streampipes-client/src/main/java/org/apache/streampipes/client/http/HttpRequest.java
+++ b/streampipes-client/src/main/java/org/apache/streampipes/client/http/HttpRequest.java
@@ -102,7 +102,7 @@ public abstract class HttpRequest<SO, DSO, DT> {
}
}
} catch (IOException | SpRuntimeException e) {
- throw new SpRuntimeException("Could not connect to the StreamPipes API - please check that StreamPipes is available");
+ throw new SpRuntimeException("Could not connect to the StreamPipes API - please check that StreamPipes is available", e);
}
}
diff --git a/streampipes-container-extensions/src/main/java/org/apache/streampipes/container/extensions/function/StreamPipesFunctionHandler.java b/streampipes-container-extensions/src/main/java/org/apache/streampipes/container/extensions/function/FunctionDeregistrationHandler.java
similarity index 53%
copy from streampipes-container-extensions/src/main/java/org/apache/streampipes/container/extensions/function/StreamPipesFunctionHandler.java
copy to streampipes-container-extensions/src/main/java/org/apache/streampipes/container/extensions/function/FunctionDeregistrationHandler.java
index d4985decf..5a9cb2641 100644
--- a/streampipes-container-extensions/src/main/java/org/apache/streampipes/container/extensions/function/StreamPipesFunctionHandler.java
+++ b/streampipes-container-extensions/src/main/java/org/apache/streampipes/container/extensions/function/FunctionDeregistrationHandler.java
@@ -18,33 +18,28 @@
package org.apache.streampipes.container.extensions.function;
-import org.apache.streampipes.container.declarer.IStreamPipesFunctionDeclarer;
-import org.apache.streampipes.container.init.DeclarersSingleton;
+import org.apache.streampipes.client.StreamPipesClient;
+import org.apache.streampipes.model.function.FunctionDefinition;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.List;
-public enum StreamPipesFunctionHandler {
+public class FunctionDeregistrationHandler extends RegistrationHandler {
- INSTANCE;
+ private static final Logger LOG = LoggerFactory.getLogger(FunctionDeregistrationHandler.class);
- private final Map<String, IStreamPipesFunctionDeclarer> runningInstances;
-
- StreamPipesFunctionHandler() {
- this.runningInstances = new HashMap<>();
+ public FunctionDeregistrationHandler(List<FunctionDefinition> functions) {
+ super(functions);
}
- public void initializeFunctions() {
- DeclarersSingleton.getInstance().getFunctions().forEach((key, value) -> {
- Runnable r = value::invokeRuntime;
- new Thread(r).start();
- runningInstances.put(key, value);
- });
+ @Override
+ protected void performRequest(StreamPipesClient client) {
+ client.adminApi().deregisterFunctions(functions);
}
- public void cleanupFunctions() {
- this.runningInstances.forEach((key, value) -> {
- value.discardRuntime();
- });
+ @Override
+ protected void logSuccess() {
+ LOG.info("Successfully deregistered functions {}", functions.toString());
}
}
diff --git a/streampipes-client/src/main/java/org/apache/streampipes/client/credentials/StreamPipesApiKeyCredentials.java b/streampipes-container-extensions/src/main/java/org/apache/streampipes/container/extensions/function/FunctionRegistrationHandler.java
similarity index 53%
copy from streampipes-client/src/main/java/org/apache/streampipes/client/credentials/StreamPipesApiKeyCredentials.java
copy to streampipes-container-extensions/src/main/java/org/apache/streampipes/container/extensions/function/FunctionRegistrationHandler.java
index 34aecc911..9ef99f958 100644
--- a/streampipes-client/src/main/java/org/apache/streampipes/client/credentials/StreamPipesApiKeyCredentials.java
+++ b/streampipes-container-extensions/src/main/java/org/apache/streampipes/container/extensions/function/FunctionRegistrationHandler.java
@@ -15,38 +15,31 @@
* limitations under the License.
*
*/
-package org.apache.streampipes.client.credentials;
-import org.apache.http.Header;
-import org.apache.streampipes.client.http.header.Headers;
+package org.apache.streampipes.container.extensions.function;
-import java.util.Arrays;
-import java.util.List;
+import org.apache.streampipes.client.StreamPipesClient;
+import org.apache.streampipes.model.function.FunctionDefinition;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-public class StreamPipesApiKeyCredentials implements CredentialsProvider {
+import java.util.List;
- private String username;
- private String apiKey;
+public class FunctionRegistrationHandler extends RegistrationHandler {
- public StreamPipesApiKeyCredentials(String username,
- String apiKey) {
- this.username = username;
- this.apiKey = apiKey;
- }
+ private static final Logger LOG = LoggerFactory.getLogger(FunctionRegistrationHandler.class);
- public String getUsername() {
- return username;
+ public FunctionRegistrationHandler(List<FunctionDefinition> functions) {
+ super(functions);
}
- public String getApiKey() {
- return apiKey;
+ @Override
+ protected void performRequest(StreamPipesClient client) {
+ client.adminApi().registerFunctions(functions);
}
@Override
- public List<Header> makeHeaders() {
- return Arrays.asList(
- Headers.xApiUser(username),
- Headers.xApiKey(apiKey)
- );
+ protected void logSuccess() {
+ LOG.info("Successfully registered functions {}", functions.toString());
}
}
diff --git a/streampipes-container-extensions/src/main/java/org/apache/streampipes/container/extensions/function/RegistrationHandler.java b/streampipes-container-extensions/src/main/java/org/apache/streampipes/container/extensions/function/RegistrationHandler.java
new file mode 100644
index 000000000..f3abf50b2
--- /dev/null
+++ b/streampipes-container-extensions/src/main/java/org/apache/streampipes/container/extensions/function/RegistrationHandler.java
@@ -0,0 +1,72 @@
+/*
+ * 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.streampipes.container.extensions.function;
+
+import org.apache.streampipes.client.StreamPipesClient;
+import org.apache.streampipes.model.function.FunctionDefinition;
+import org.apache.streampipes.service.extensions.base.client.StreamPipesClientResolver;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+public abstract class RegistrationHandler implements Runnable {
+
+ private static final Logger LOG = LoggerFactory.getLogger(FunctionRegistrationHandler.class);
+ private static final int MAX_RETRIES = 3;
+ private static final long WAIT_TIME_BETWEEN_RETRIES = 5000;
+
+ protected final List<FunctionDefinition> functions;
+
+ public RegistrationHandler(List<FunctionDefinition> functions) {
+ this.functions = functions;
+ }
+
+ public void run() {
+ initRequest(0);
+ }
+
+ public void initRequest(int retryCount) {
+ try {
+ var client = getStreamPipesClient();
+ performRequest(client);
+ logSuccess();
+ } catch (Exception e) {
+ if (retryCount < MAX_RETRIES) {
+ LOG.warn("Could not execute registration request", e);
+ try {
+ TimeUnit.MILLISECONDS.sleep(WAIT_TIME_BETWEEN_RETRIES);
+ } catch (InterruptedException ex) {
+ LOG.error("Error while initiating sleep", ex);
+ }
+ retryCount++;
+ initRequest(retryCount);
+ }
+ }
+ }
+
+ protected abstract void performRequest(StreamPipesClient client);
+
+ protected abstract void logSuccess();
+
+ private StreamPipesClient getStreamPipesClient() {
+ return new StreamPipesClientResolver().makeStreamPipesClientInstance();
+ }
+}
diff --git a/streampipes-container-extensions/src/main/java/org/apache/streampipes/container/extensions/function/StreamPipesFunctionHandler.java b/streampipes-container-extensions/src/main/java/org/apache/streampipes/container/extensions/function/StreamPipesFunctionHandler.java
index d4985decf..796ee0ddd 100644
--- a/streampipes-container-extensions/src/main/java/org/apache/streampipes/container/extensions/function/StreamPipesFunctionHandler.java
+++ b/streampipes-container-extensions/src/main/java/org/apache/streampipes/container/extensions/function/StreamPipesFunctionHandler.java
@@ -20,9 +20,13 @@ package org.apache.streampipes.container.extensions.function;
import org.apache.streampipes.container.declarer.IStreamPipesFunctionDeclarer;
import org.apache.streampipes.container.init.DeclarersSingleton;
+import org.apache.streampipes.model.function.FunctionDefinition;
+import org.apache.streampipes.model.function.FunctionId;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
+import java.util.stream.Collectors;
public enum StreamPipesFunctionHandler {
@@ -40,11 +44,22 @@ public enum StreamPipesFunctionHandler {
new Thread(r).start();
runningInstances.put(key, value);
});
+ new Thread(new FunctionRegistrationHandler(getFunctionDefinitions())).start();
}
public void cleanupFunctions() {
- this.runningInstances.forEach((key, value) -> {
- value.discardRuntime();
- });
+ this.runningInstances.forEach((key, value) -> {
+ value.discardRuntime();
+ });
+ new Thread(new FunctionDeregistrationHandler(getFunctionDefinitions())).start();
+ }
+
+ private List<FunctionDefinition> getFunctionDefinitions() {
+ return this.runningInstances
+ .values()
+ .stream()
+ .map(function -> new FunctionDefinition(function.getFunctionId(), function.requiredStreamIds()))
+ .collect(Collectors.toList());
}
+
}
diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/function/FunctionDefinition.java b/streampipes-model/src/main/java/org/apache/streampipes/model/function/FunctionDefinition.java
new file mode 100644
index 000000000..2d0ad972f
--- /dev/null
+++ b/streampipes-model/src/main/java/org/apache/streampipes/model/function/FunctionDefinition.java
@@ -0,0 +1,63 @@
+/*
+ * 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.streampipes.model.function;
+
+import org.apache.streampipes.model.shared.annotation.TsModel;
+
+import java.util.List;
+
+@TsModel
+public class FunctionDefinition {
+
+ private FunctionId functionId;
+ private List<String> consumedStreams;
+
+ public FunctionDefinition() {
+ }
+
+ public FunctionDefinition(FunctionId functionId, List<String> consumedStreams) {
+ this.functionId = functionId;
+ this.consumedStreams = consumedStreams;
+ }
+
+ public FunctionId getFunctionId() {
+ return functionId;
+ }
+
+ public void setFunctionId(FunctionId functionId) {
+ this.functionId = functionId;
+ }
+
+ public List<String> getConsumedStreams() {
+ return consumedStreams;
+ }
+
+ public void setConsumedStreams(List<String> consumedStreams) {
+ this.consumedStreams = consumedStreams;
+ }
+
+ @Override
+ public String toString() {
+ return "FunctionDefinition{" +
+ "functionId=" + functionId.toString() +
+ ", consumedStreams=" + consumedStreams.toString() +
+ '}';
+ }
+}
diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/function/FunctionId.java b/streampipes-model/src/main/java/org/apache/streampipes/model/function/FunctionId.java
index 7c2fdc18d..bf5d7b687 100644
--- a/streampipes-model/src/main/java/org/apache/streampipes/model/function/FunctionId.java
+++ b/streampipes-model/src/main/java/org/apache/streampipes/model/function/FunctionId.java
@@ -18,6 +18,9 @@
package org.apache.streampipes.model.function;
+import org.apache.streampipes.model.shared.annotation.TsModel;
+
+@TsModel
public class FunctionId {
private String id;
@@ -28,6 +31,9 @@ public class FunctionId {
return new FunctionId(id, version);
}
+ public FunctionId() {
+ }
+
private FunctionId(String id,
int version) {
this.id = id;
@@ -41,4 +47,20 @@ public class FunctionId {
public int getVersion() {
return version;
}
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public void setVersion(int version) {
+ this.version = version;
+ }
+
+ @Override
+ public String toString() {
+ return "FunctionId{" +
+ "id='" + id + '\'' +
+ ", version=" + version +
+ '}';
+ }
}
diff --git a/streampipes-container-extensions/src/main/java/org/apache/streampipes/container/extensions/function/StreamPipesFunctionHandler.java b/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/function/FunctionRegistrationService.java
similarity index 53%
copy from streampipes-container-extensions/src/main/java/org/apache/streampipes/container/extensions/function/StreamPipesFunctionHandler.java
copy to streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/function/FunctionRegistrationService.java
index d4985decf..e6382486c 100644
--- a/streampipes-container-extensions/src/main/java/org/apache/streampipes/container/extensions/function/StreamPipesFunctionHandler.java
+++ b/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/function/FunctionRegistrationService.java
@@ -16,35 +16,34 @@
*
*/
-package org.apache.streampipes.container.extensions.function;
+package org.apache.streampipes.manager.function;
-import org.apache.streampipes.container.declarer.IStreamPipesFunctionDeclarer;
-import org.apache.streampipes.container.init.DeclarersSingleton;
+import org.apache.streampipes.model.function.FunctionDefinition;
+import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
-public enum StreamPipesFunctionHandler {
+public enum FunctionRegistrationService {
INSTANCE;
- private final Map<String, IStreamPipesFunctionDeclarer> runningInstances;
+ Map<String, FunctionDefinition> registeredFunctions;
- StreamPipesFunctionHandler() {
- this.runningInstances = new HashMap<>();
+ FunctionRegistrationService() {
+ this.registeredFunctions = new HashMap<>();
}
- public void initializeFunctions() {
- DeclarersSingleton.getInstance().getFunctions().forEach((key, value) -> {
- Runnable r = value::invokeRuntime;
- new Thread(r).start();
- runningInstances.put(key, value);
- });
+ public Collection<FunctionDefinition> getAllFunctions() {
+ return registeredFunctions.values();
}
- public void cleanupFunctions() {
- this.runningInstances.forEach((key, value) -> {
- value.discardRuntime();
- });
+ public void registerFunction(FunctionDefinition function) {
+ this.registeredFunctions.put(function.getFunctionId().getId(), function);
+ }
+
+ public void deregisterFunction(FunctionDefinition function) {
+
+ this.registeredFunctions.remove(function.getFunctionId().getId());
}
}
diff --git a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/monitoring/pipeline/ExtensionsLogProvider.java b/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/monitoring/pipeline/ExtensionsLogProvider.java
index dd94abd77..521abc5c5 100644
--- a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/monitoring/pipeline/ExtensionsLogProvider.java
+++ b/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/monitoring/pipeline/ExtensionsLogProvider.java
@@ -74,11 +74,11 @@ public enum ExtensionsLogProvider {
return getLogInfosForPipeline(pipeline);
}
- public List<SpLogEntry> getLogInfosForAdapter(String resourceId) {
+ public List<SpLogEntry> getLogInfosForResource(String resourceId) {
return allLogInfos.getOrDefault(resourceId, Collections.emptyList());
}
- public SpMetricsEntry getMetricInfosForAdapter(String resourceId) {
+ public SpMetricsEntry getMetricInfosForResource(String resourceId) {
if (allMetricsInfos.containsKey(resourceId)) {
return allMetricsInfos.get(resourceId);
} else {
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/AdapterMonitoringResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/AdapterMonitoringResource.java
index 926fa1e02..bb96a1ad6 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/AdapterMonitoringResource.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/AdapterMonitoringResource.java
@@ -35,13 +35,13 @@ public class AdapterMonitoringResource extends AbstractMonitoringResource {
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getLogInfoForAdapter(@PathParam("elementId") String elementId) {
- return ok(ExtensionsLogProvider.INSTANCE.getLogInfosForAdapter(elementId));
+ return ok(ExtensionsLogProvider.INSTANCE.getLogInfosForResource(elementId));
}
@Path("adapter/{elementId}/metrics")
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getMetricsInfoForAdapter(@PathParam("elementId") String elementId) {
- return ok(ExtensionsLogProvider.INSTANCE.getMetricInfosForAdapter(elementId));
+ return ok(ExtensionsLogProvider.INSTANCE.getMetricInfosForResource(elementId));
}
}
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/FunctionsResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/FunctionsResource.java
new file mode 100644
index 000000000..ffaafbe9a
--- /dev/null
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/FunctionsResource.java
@@ -0,0 +1,70 @@
+/*
+ * 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.streampipes.rest.impl;
+
+import org.apache.streampipes.manager.function.FunctionRegistrationService;
+import org.apache.streampipes.manager.monitoring.pipeline.ExtensionsLogProvider;
+import org.apache.streampipes.model.function.FunctionDefinition;
+import org.apache.streampipes.model.function.FunctionId;
+import org.apache.streampipes.model.message.Notifications;
+import org.apache.streampipes.rest.core.base.impl.AbstractAuthGuardedRestResource;
+
+import javax.ws.rs.*;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.util.List;
+
+@Path("/v2/functions")
+public class FunctionsResource extends AbstractAuthGuardedRestResource {
+
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response getActiveFunctions() {
+ return ok(FunctionRegistrationService.INSTANCE.getAllFunctions());
+ }
+
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response registerFunctions(List<FunctionDefinition> functions) {
+ functions.forEach(FunctionRegistrationService.INSTANCE::registerFunction);
+ return ok(Notifications.success("Function successfully registered"));
+ }
+
+ @DELETE
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response deregisterFunction(List<FunctionDefinition> functions) {
+ functions.forEach(FunctionRegistrationService.INSTANCE::deregisterFunction);
+ return ok(Notifications.success("Function successfully deregistered"));
+ }
+
+ @GET
+ @Path("{functionId}/metrics")
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response getFunctionMetrics(@PathParam("functionId") String functionId) {
+ return ok(ExtensionsLogProvider.INSTANCE.getMetricInfosForResource(functionId));
+ }
+
+ @GET
+ @Path("{functionId}/logs")
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response getFunctionLogs(@PathParam("functionId") String functionId) {
+ return ok(ExtensionsLogProvider.INSTANCE.getLogInfosForResource(functionId));
+ }
+}
diff --git a/streampipes-wrapper-standalone/src/main/java/org/apache/streampipes/wrapper/standalone/function/StreamPipesFunction.java b/streampipes-wrapper-standalone/src/main/java/org/apache/streampipes/wrapper/standalone/function/StreamPipesFunction.java
index 7df352a22..8d4a9fcad 100644
--- a/streampipes-wrapper-standalone/src/main/java/org/apache/streampipes/wrapper/standalone/function/StreamPipesFunction.java
+++ b/streampipes-wrapper-standalone/src/main/java/org/apache/streampipes/wrapper/standalone/function/StreamPipesFunction.java
@@ -68,8 +68,9 @@ public abstract class StreamPipesFunction implements IStreamPipesFunctionDeclare
@Override
public void process(Map<String, Object> rawEvent, String sourceInfo) {
try {
- this.onEvent(EventFactory.fromMap(rawEvent), sourceInfoMapper.get(sourceInfo));
- increaseCounter(sourceInfo);
+ var elementId = sourceInfoMapper.get(sourceInfo);
+ this.onEvent(EventFactory.fromMap(rawEvent), elementId);
+ increaseCounter(elementId);
} catch (RuntimeException e) {
addError(e);
}
diff --git a/ui/projects/streampipes/platform-services/src/lib/apis/functions.service.ts b/ui/projects/streampipes/platform-services/src/lib/apis/functions.service.ts
new file mode 100644
index 000000000..d7aca9d2f
--- /dev/null
+++ b/ui/projects/streampipes/platform-services/src/lib/apis/functions.service.ts
@@ -0,0 +1,53 @@
+/*
+ * 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 { Injectable } from '@angular/core';
+import { HttpClient } from '@angular/common/http';
+import { PlatformServicesCommons } from './commons.service';
+import { FunctionDefinition, SpLogEntry, SpMetricsEntry } from '../model/gen/streampipes-model';
+import { Observable } from 'rxjs';
+import { map } from 'rxjs/operators';
+
+@Injectable({
+ providedIn: 'root'
+})
+export class FunctionsService {
+
+ constructor(
+ private http: HttpClient,
+ private platformServicesCommons: PlatformServicesCommons) {
+ }
+
+ public getActiveFunctions(): Observable<FunctionDefinition[]> {
+ return this.http.get(this.functionsPath).pipe(map(res => res as FunctionDefinition[]));
+ }
+
+ public getFunctionLogs(functionId: string): Observable<SpLogEntry[]> {
+ return this.http.get(`${this.functionsPath}/${functionId}/logs`)
+ .pipe(map(res => res as SpLogEntry[]));
+ }
+
+ public getFunctionMetrics(functionId: string): Observable<SpMetricsEntry> {
+ return this.http.get(`${this.functionsPath}/${functionId}/metrics`)
+ .pipe(map(res => res as SpMetricsEntry));
+ }
+
+ private get functionsPath() {
+ return this.platformServicesCommons.apiBasePath + '/functions';
+ }
+}
diff --git a/ui/projects/streampipes/platform-services/src/lib/model/gen/streampipes-model.ts b/ui/projects/streampipes/platform-services/src/lib/model/gen/streampipes-model.ts
index c81e5b7f8..ab30779a0 100644
--- a/ui/projects/streampipes/platform-services/src/lib/model/gen/streampipes-model.ts
+++ b/ui/projects/streampipes/platform-services/src/lib/model/gen/streampipes-model.ts
@@ -19,7 +19,7 @@
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
-// Generated using typescript-generator version 2.27.744 on 2022-10-19 15:02:22.
+// Generated using typescript-generator version 2.27.744 on 2022-10-23 22:36:57.
export class AbstractStreamPipesEntity {
"@class": "org.apache.streampipes.model.base.AbstractStreamPipesEntity" | "org.apache.streampipes.model.base.NamedStreamPipesEntity" | "org.apache.streampipes.model.connect.adapter.AdapterDescription" | "org.apache.streampipes.model.connect.adapter.AdapterSetDescription" | "org.apache.streampipes.model.connect.adapter.GenericAdapterSetDescription" | "org.apache.streampipes.model.connect.adapter.SpecificAdapterSetDescription" | "org.apache.streampipes.model.connect.adapter.AdapterStre [...]
@@ -173,7 +173,6 @@ export class AdapterDescription extends NamedStreamPipesEntity {
schemaRules: TransformationRuleDescriptionUnion[];
selectedEndpointUrl: string;
streamRules: TransformationRuleDescriptionUnion[];
- userName: string;
valueRules: TransformationRuleDescriptionUnion[];
static fromData(data: AdapterDescription, target?: AdapterDescription): AdapterDescription {
@@ -182,7 +181,6 @@ export class AdapterDescription extends NamedStreamPipesEntity {
}
const instance = target || new AdapterDescription();
super.fromData(data, instance);
- instance.userName = data.userName;
instance.eventGrounding = EventGrounding.fromData(data.eventGrounding);
instance.adapterType = data.adapterType;
instance.icon = data.icon;
@@ -193,10 +191,9 @@ export class AdapterDescription extends NamedStreamPipesEntity {
instance.selectedEndpointUrl = data.selectedEndpointUrl;
instance.correspondingServiceGroup = data.correspondingServiceGroup;
instance.correspondingDataStreamElementId = data.correspondingDataStreamElementId;
- instance.schemaRules = __getCopyArrayFn(TransformationRuleDescription.fromDataUnion)(data.schemaRules);
instance.streamRules = __getCopyArrayFn(TransformationRuleDescription.fromDataUnion)(data.streamRules);
+ instance.schemaRules = __getCopyArrayFn(TransformationRuleDescription.fromDataUnion)(data.schemaRules);
instance.valueRules = __getCopyArrayFn(TransformationRuleDescription.fromDataUnion)(data.valueRules);
-
return instance;
}
@@ -1773,6 +1770,36 @@ export class Frequency extends EventStreamQualityDefinition {
}
}
+export class FunctionDefinition {
+ consumedStreams: string[];
+ functionId: FunctionId;
+
+ static fromData(data: FunctionDefinition, target?: FunctionDefinition): FunctionDefinition {
+ if (!data) {
+ return data;
+ }
+ const instance = target || new FunctionDefinition();
+ instance.functionId = FunctionId.fromData(data.functionId);
+ instance.consumedStreams = __getCopyArrayFn(__identity<string>())(data.consumedStreams);
+ return instance;
+ }
+}
+
+export class FunctionId {
+ id: string;
+ version: number;
+
+ static fromData(data: FunctionId, target?: FunctionId): FunctionId {
+ if (!data) {
+ return data;
+ }
+ const instance = target || new FunctionId();
+ instance.id = data.id;
+ instance.version = data.version;
+ return instance;
+ }
+}
+
export interface GenericAdapterDescription {
eventSchema: EventSchema;
formatDescription: FormatDescription;
@@ -1792,10 +1819,9 @@ export class GenericAdapterSetDescription extends AdapterSetDescription implemen
}
const instance = target || new GenericAdapterSetDescription();
super.fromData(data, instance);
- instance.eventSchema = EventSchema.fromData(data.eventSchema);
instance.formatDescription = FormatDescription.fromData(data.formatDescription);
- instance.eventSchema = EventSchema.fromData(data.eventSchema);
instance.protocolDescription = ProtocolDescription.fromData(data.protocolDescription);
+ instance.eventSchema = EventSchema.fromData(data.eventSchema);
return instance;
}
}
@@ -1812,10 +1838,9 @@ export class GenericAdapterStreamDescription extends AdapterStreamDescription im
}
const instance = target || new GenericAdapterStreamDescription();
super.fromData(data, instance);
- instance.eventSchema = EventSchema.fromData(data.eventSchema);
instance.formatDescription = FormatDescription.fromData(data.formatDescription);
- instance.eventSchema = EventSchema.fromData(data.eventSchema);
instance.protocolDescription = ProtocolDescription.fromData(data.protocolDescription);
+ instance.eventSchema = EventSchema.fromData(data.eventSchema);
return instance;
}
}
@@ -2677,9 +2702,8 @@ export class PipelineTemplateDescription extends NamedStreamPipesEntity {
const instance = target || new PipelineTemplateDescription();
super.fromData(data, instance);
instance.boundTo = __getCopyArrayFn(BoundPipelineElement.fromData)(data.boundTo);
- instance.pipelineTemplateId = data.pipelineTemplateId;
instance.pipelineTemplateName = data.pipelineTemplateName;
-
+ instance.pipelineTemplateId = data.pipelineTemplateId;
instance.pipelineTemplateDescription = data.pipelineTemplateDescription;
return instance;
}
diff --git a/ui/projects/streampipes/platform-services/src/public-api.ts b/ui/projects/streampipes/platform-services/src/public-api.ts
index d032d4d15..2240e2b1f 100644
--- a/ui/projects/streampipes/platform-services/src/public-api.ts
+++ b/ui/projects/streampipes/platform-services/src/public-api.ts
@@ -31,6 +31,7 @@ export * from './lib/apis/data-view-data-explorer.service';
export * from './lib/apis/datalake-rest.service';
export * from './lib/apis/dashboard.service';
export * from './lib/apis/files.service';
+export * from './lib/apis/functions.service';
export * from './lib/apis/general-config.service';
export * from './lib/apis/generic-storage.service';
export * from './lib/apis/mail-config.service';
diff --git a/ui/src/app/connect/components/adapter-details/adapter-details-logs/adapter-details-logs.component.html b/ui/src/app/connect/components/adapter-details/adapter-details-logs/adapter-details-logs.component.html
index b9a3609a1..08526dcc3 100644
--- a/ui/src/app/connect/components/adapter-details/adapter-details-logs/adapter-details-logs.component.html
+++ b/ui/src/app/connect/components/adapter-details/adapter-details-logs/adapter-details-logs.component.html
@@ -32,19 +32,10 @@
</button>
</div>
<div fxFlex="100" fxLayout="column" *ngIf="adapter">
- <sp-basic-header-title-component [title]="adapter.name + ' - Logs'"></sp-basic-header-title-component>
- <div fxFlex="100" fxLayout="column" fxLayoutAlign="center center" *ngIf="!adapterLogs || adapterLogs.length === 0">
- <h5 class="text-center">(no log messages available)</h5>
- </div>
- <div fxFlex="100" fxLayout="column" *ngIf="adapterLogs && adapterLogs.length > 0">
- <div *ngFor="let logEntry of adapterLogs">
- <sp-exception-message [message]="logEntry.errorMessage"
- [messageTimestamp]="logEntry.timestamp"
- *ngIf="logEntry.errorMessage"
- class="mt-10">
- </sp-exception-message>
- </div>
- </div>
+ <sp-simple-logs [elementName]="adapter.name"
+ [logs]="adapterLogs"
+ fxFlex="100"
+ fxLayout="column"></sp-simple-logs>
</div>
diff --git a/ui/src/app/connect/components/adapter-details/adapter-details-metrics/adapter-details-metrics.component.html b/ui/src/app/connect/components/adapter-details/adapter-details-metrics/adapter-details-metrics.component.html
index 906f9ba7c..8e602c2c5 100644
--- a/ui/src/app/connect/components/adapter-details/adapter-details-metrics/adapter-details-metrics.component.html
+++ b/ui/src/app/connect/components/adapter-details/adapter-details-metrics/adapter-details-metrics.component.html
@@ -31,23 +31,12 @@
</button>
</div>
<div fxFlex="100" fxLayout="column" *ngIf="adapter && adapterMetrics">
- <sp-basic-header-title-component [title]="adapter.name + ' - Metrics'"></sp-basic-header-title-component>
- <div fxLayout="row" fxLayoutAlign="center center">
- <div fxFlex="50">
- <sp-status-widget fxFlex="100" label="Last published message"
- [widgetHeight]="400"
- [widgetWidth]="500"
- [statusValue]="adapterMetrics.lastTimestamp === 0 ? 'n/a' : (adapterMetrics.lastTimestamp | date : 'medium')">
- </sp-status-widget>
- </div>
- <div fxFlex="50">
- <sp-status-widget fxFlex="100" label="Published messages"
- [widgetHeight]="400"
- [widgetWidth]="500"
- [statusValue]="adapterMetrics.messagesOut.counter">
- </sp-status-widget>
- </div>
- </div>
+ <sp-simple-metrics [elementName]="adapter.name"
+ lastPublishedLabel="Last published message"
+ statusValueLabel="Published messages"
+ [lastTimestamp]="adapterMetrics.lastTimestamp"
+ [statusValue]="adapterMetrics.messagesOut.counter">
+ </sp-simple-metrics>
</div>
diff --git a/ui/src/app/connect/components/adapter-details/adapter-details-metrics/adapter-details-metrics.component.ts b/ui/src/app/connect/components/adapter-details/adapter-details-metrics/adapter-details-metrics.component.ts
index d5a9b910e..4544d04ce 100644
--- a/ui/src/app/connect/components/adapter-details/adapter-details-metrics/adapter-details-metrics.component.ts
+++ b/ui/src/app/connect/components/adapter-details/adapter-details-metrics/adapter-details-metrics.component.ts
@@ -27,7 +27,7 @@ import { SpConnectRoutes } from '../../../connect.routes';
@Component({
selector: 'sp-adapter-details-metrics',
templateUrl: './adapter-details-metrics.component.html',
- styleUrls: ['./adapter-details-metrics.component.scss']
+ styleUrls: []
})
export class SpAdapterDetailsMetricsComponent extends SpAbstractAdapterDetailsDirective implements OnInit {
diff --git a/ui/src/app/core-ui/core-ui.module.ts b/ui/src/app/core-ui/core-ui.module.ts
index fcc569664..1c845ab78 100644
--- a/ui/src/app/core-ui/core-ui.module.ts
+++ b/ui/src/app/core-ui/core-ui.module.ts
@@ -98,6 +98,8 @@ import { DownloadComponent } from './data-download-dialog/components/download/do
import { SelectDataRangeComponent } from './data-download-dialog/components/select-data/select-data-range/select-data-range.component';
import { SelectDataMissingValuesComponent } from './data-download-dialog/components/select-data/select-data-missing-values/select-data-missing-values.component';
import { StatusWidgetComponent } from './status/status-widget.component';
+import { SpSimpleMetricsComponent } from './monitoring/simple-metrics/simple-metrics.component';
+import { SpSimpleLogsComponent } from './monitoring/simple-logs/simple-logs.component';
@NgModule({
imports: [
@@ -171,6 +173,8 @@ import { StatusWidgetComponent } from './status/status-widget.component';
DownloadComponent,
SelectDataRangeComponent,
SelectDataMissingValuesComponent,
+ SpSimpleLogsComponent,
+ SpSimpleMetricsComponent,
StatusWidgetComponent
],
providers: [
@@ -211,6 +215,8 @@ import { StatusWidgetComponent } from './status/status-widget.component';
ErrorHintComponent,
PipelineStartedStatusComponent,
SplitSectionComponent,
+ SpSimpleLogsComponent,
+ SpSimpleMetricsComponent,
StatusWidgetComponent
]
})
diff --git a/ui/src/app/core-ui/monitoring/simple-logs/simple-logs.component.html b/ui/src/app/core-ui/monitoring/simple-logs/simple-logs.component.html
new file mode 100644
index 000000000..983b30b63
--- /dev/null
+++ b/ui/src/app/core-ui/monitoring/simple-logs/simple-logs.component.html
@@ -0,0 +1,33 @@
+<!--
+ ~ 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.
+ ~
+ -->
+
+<div fxFlex="100" fxLayout="column">
+ <sp-basic-header-title-component [title]="elementName + ' - Logs'"></sp-basic-header-title-component>
+ <div fxFlex="100" fxLayout="column" fxLayoutAlign="center center" *ngIf="!logs || logs.length === 0">
+ <h5 class="text-center">(no log messages available)</h5>
+ </div>
+ <div fxFlex="100" fxLayout="column" *ngIf="logs && logs.length > 0">
+ <div *ngFor="let logEntry of logs">
+ <sp-exception-message [message]="logEntry.errorMessage"
+ [messageTimestamp]="logEntry.timestamp"
+ *ngIf="logEntry.errorMessage"
+ class="mt-10">
+ </sp-exception-message>
+ </div>
+ </div>
+</div>
diff --git a/ui/src/app/pipelines/pipelines.routes.ts b/ui/src/app/core-ui/monitoring/simple-logs/simple-logs.component.ts
similarity index 71%
copy from ui/src/app/pipelines/pipelines.routes.ts
copy to ui/src/app/core-ui/monitoring/simple-logs/simple-logs.component.ts
index 5b4ccc7fb..529aac9e2 100644
--- a/ui/src/app/pipelines/pipelines.routes.ts
+++ b/ui/src/app/core-ui/monitoring/simple-logs/simple-logs.component.ts
@@ -16,10 +16,19 @@
*
*/
-import { SpBreadcrumbItem, } from '@streampipes/shared-ui';
+import { Component, Input } from '@angular/core';
+import { SpLogEntry } from '@streampipes/platform-services';
-export class SpPipelineRoutes {
+@Component({
+ selector: 'sp-simple-logs',
+ templateUrl: './simple-logs.component.html',
+ styleUrls: []
+})
+export class SpSimpleLogsComponent {
- static BASE: SpBreadcrumbItem = {label: 'Pipelines', link: ['pipelines']};
+ @Input()
+ logs: SpLogEntry[] = [];
+ @Input()
+ elementName: string;
}
diff --git a/ui/src/app/core-ui/monitoring/simple-metrics/simple-metrics.component.html b/ui/src/app/core-ui/monitoring/simple-metrics/simple-metrics.component.html
new file mode 100644
index 000000000..3c428251b
--- /dev/null
+++ b/ui/src/app/core-ui/monitoring/simple-metrics/simple-metrics.component.html
@@ -0,0 +1,35 @@
+<!--
+ ~ 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.
+ ~
+ -->
+
+<sp-basic-header-title-component [title]="elementName + ' - Metrics'"></sp-basic-header-title-component>
+<div fxLayout="row" fxLayoutAlign="center center">
+ <div fxFlex="50">
+ <sp-status-widget fxFlex="100" [label]="lastPublishedLabel"
+ [widgetHeight]="400"
+ [widgetWidth]="500"
+ [statusValue]="lastTimestamp === 0 ? 'n/a' : (lastTimestamp | date : 'medium')">
+ </sp-status-widget>
+ </div>
+ <div fxFlex="50">
+ <sp-status-widget fxFlex="100" [label]="statusValueLabel"
+ [widgetHeight]="400"
+ [widgetWidth]="500"
+ [statusValue]="statusValue">
+ </sp-status-widget>
+ </div>
+</div>
diff --git a/ui/src/app/pipelines/pipelines.routes.ts b/ui/src/app/core-ui/monitoring/simple-metrics/simple-metrics.component.ts
similarity index 66%
copy from ui/src/app/pipelines/pipelines.routes.ts
copy to ui/src/app/core-ui/monitoring/simple-metrics/simple-metrics.component.ts
index 5b4ccc7fb..5077c873c 100644
--- a/ui/src/app/pipelines/pipelines.routes.ts
+++ b/ui/src/app/core-ui/monitoring/simple-metrics/simple-metrics.component.ts
@@ -16,10 +16,27 @@
*
*/
-import { SpBreadcrumbItem, } from '@streampipes/shared-ui';
+import { Component, Input } from '@angular/core';
-export class SpPipelineRoutes {
+@Component({
+ selector: 'sp-simple-metrics',
+ templateUrl: './simple-metrics.component.html',
+ styleUrls: []
+})
+export class SpSimpleMetricsComponent {
- static BASE: SpBreadcrumbItem = {label: 'Pipelines', link: ['pipelines']};
+ @Input()
+ elementName: string;
+ @Input()
+ lastTimestamp: number;
+
+ @Input()
+ statusValue: string | number;
+
+ @Input()
+ lastPublishedLabel: string;
+
+ @Input()
+ statusValueLabel: string;
}
diff --git a/ui/src/app/pipelines/components/functions-overview/abstract-function-details.directive.ts b/ui/src/app/pipelines/components/functions-overview/abstract-function-details.directive.ts
new file mode 100644
index 000000000..fce2c1ce9
--- /dev/null
+++ b/ui/src/app/pipelines/components/functions-overview/abstract-function-details.directive.ts
@@ -0,0 +1,81 @@
+/*
+ * 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 { ActivatedRoute } from '@angular/router';
+import {
+ AdapterMonitoringService,
+ FunctionDefinition,
+ FunctionsService,
+ PipelineElementService,
+ SpDataStream
+} from '@streampipes/platform-services';
+import { Directive } from '@angular/core';
+import { Observable, zip } from 'rxjs';
+
+@Directive()
+export abstract class AbstractFunctionDetailsDirective {
+
+ public activeFunction: FunctionDefinition;
+
+ contentReady = false;
+ tabs = [];
+ streamNames: Record<string, string> = {};
+
+ constructor(private route: ActivatedRoute,
+ protected functionsService: FunctionsService,
+ private pipelineElementService: PipelineElementService,
+ private adapterMonitoringService: AdapterMonitoringService) {
+ }
+
+ onInit() {
+ const functionId = this.route.snapshot.params.functionId;
+ this.tabs = [
+ {itemId: 'metrics', itemTitle: 'Metrics', itemLink: ['pipelines', 'functions', functionId, 'metrics']},
+ {itemId: 'logs', itemTitle: 'Logs', itemLink: ['pipelines', 'functions', functionId, 'logs']}
+ ]
+ this.loadFunctions(functionId);
+ }
+
+ loadFunctions(functionId: string) {
+ this.functionsService.getActiveFunctions().subscribe(functions => {
+ this.activeFunction = functions.find(f => f.functionId.id === functionId);
+ this.loadStreams(this.activeFunction.consumedStreams);
+ })
+ }
+
+ loadStreams(relatedStreams: string[]) {
+ this.streamNames = {};
+ const observables = this.getStreamObservables(relatedStreams);
+ zip(...observables).subscribe(streams => {
+ streams.forEach(stream => this.streamNames[stream.elementId] = stream.name);
+ this.afterFunctionLoaded();
+ })
+ }
+
+ getStreamObservables(relatedStreams: string[]): Observable<SpDataStream>[] {
+ return relatedStreams.map(s => this.pipelineElementService.getDataStreamByElementId(s));
+ }
+
+ triggerUpdate() {
+ this.adapterMonitoringService.triggerMonitoringUpdate().subscribe(() => {
+ this.afterFunctionLoaded();
+ });
+ }
+
+ abstract afterFunctionLoaded(): void;
+}
diff --git a/ui/src/app/connect/components/adapter-details/adapter-details-logs/adapter-details-logs.component.html b/ui/src/app/pipelines/components/functions-overview/functions-logs/functions-logs.component.html
similarity index 60%
copy from ui/src/app/connect/components/adapter-details/adapter-details-logs/adapter-details-logs.component.html
copy to ui/src/app/pipelines/components/functions-overview/functions-logs/functions-logs.component.html
index b9a3609a1..dbc9f8d1d 100644
--- a/ui/src/app/connect/components/adapter-details/adapter-details-logs/adapter-details-logs.component.html
+++ b/ui/src/app/pipelines/components/functions-overview/functions-logs/functions-logs.component.html
@@ -19,8 +19,7 @@
<sp-basic-nav-tabs [spNavigationItems]="tabs"
[activeLink]="'logs'"
[showBackLink]="true"
- [backLinkTarget]="['connect']">
-
+ [backLinkTarget]="['pipelines']">
<div nav fxFlex="100" fxLayout="row" fxLayoutAlign="end center">
<button mat-button
mat-icon-button
@@ -31,20 +30,11 @@
<i class="material-icons">refresh</i>
</button>
</div>
- <div fxFlex="100" fxLayout="column" *ngIf="adapter">
- <sp-basic-header-title-component [title]="adapter.name + ' - Logs'"></sp-basic-header-title-component>
- <div fxFlex="100" fxLayout="column" fxLayoutAlign="center center" *ngIf="!adapterLogs || adapterLogs.length === 0">
- <h5 class="text-center">(no log messages available)</h5>
- </div>
- <div fxFlex="100" fxLayout="column" *ngIf="adapterLogs && adapterLogs.length > 0">
- <div *ngFor="let logEntry of adapterLogs">
- <sp-exception-message [message]="logEntry.errorMessage"
- [messageTimestamp]="logEntry.timestamp"
- *ngIf="logEntry.errorMessage"
- class="mt-10">
- </sp-exception-message>
- </div>
- </div>
+ <div fxFlex="100" fxLayout="column" *ngIf="activeFunction && contentReady">
+ <sp-simple-logs [elementName]="activeFunction.functionId.id" [logs]="logs"
+ fxFlex="100"
+ fxLayout="column">
+ </sp-simple-logs>
</div>
diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/function/FunctionId.java b/ui/src/app/pipelines/components/functions-overview/functions-logs/functions-logs.component.ts
similarity index 53%
copy from streampipes-model/src/main/java/org/apache/streampipes/model/function/FunctionId.java
copy to ui/src/app/pipelines/components/functions-overview/functions-logs/functions-logs.component.ts
index 7c2fdc18d..dcf604f26 100644
--- a/streampipes-model/src/main/java/org/apache/streampipes/model/function/FunctionId.java
+++ b/ui/src/app/pipelines/components/functions-overview/functions-logs/functions-logs.component.ts
@@ -16,29 +16,32 @@
*
*/
-package org.apache.streampipes.model.function;
+import { Component, OnInit } from '@angular/core';
+import { AbstractFunctionDetailsDirective } from '../abstract-function-details.directive';
+import { SpLogEntry } from '@streampipes/platform-services';
-public class FunctionId {
+@Component({
+ selector: 'sp-functions-logs',
+ templateUrl: './functions-logs.component.html',
+ styleUrls: []
+})
+export class SpFunctionsLogsComponent extends AbstractFunctionDetailsDirective implements OnInit {
- private String id;
- private int version;
+ logs: SpLogEntry[] = [];
- public static FunctionId from(String id,
- int version) {
- return new FunctionId(id, version);
+ ngOnInit(): void {
+ super.onInit();
}
- private FunctionId(String id,
- int version) {
- this.id = id;
- this.version = version;
+ afterFunctionLoaded(): void {
+ this.loadLogs();
}
- public String getId() {
- return id;
+ loadLogs(): void {
+ this.functionsService.getFunctionLogs(this.activeFunction.functionId.id).subscribe(logs => {
+ this.logs = logs;
+ this.contentReady = true;
+ });
}
- public int getVersion() {
- return version;
- }
}
diff --git a/ui/src/app/connect/components/adapter-details/adapter-details-logs/adapter-details-logs.component.html b/ui/src/app/pipelines/components/functions-overview/functions-metrics/functions-metrics.component.html
similarity index 59%
copy from ui/src/app/connect/components/adapter-details/adapter-details-logs/adapter-details-logs.component.html
copy to ui/src/app/pipelines/components/functions-overview/functions-metrics/functions-metrics.component.html
index b9a3609a1..c04a4d2bc 100644
--- a/ui/src/app/connect/components/adapter-details/adapter-details-logs/adapter-details-logs.component.html
+++ b/ui/src/app/pipelines/components/functions-overview/functions-metrics/functions-metrics.component.html
@@ -17,10 +17,9 @@
-->
<sp-basic-nav-tabs [spNavigationItems]="tabs"
- [activeLink]="'logs'"
+ [activeLink]="'metrics'"
[showBackLink]="true"
- [backLinkTarget]="['connect']">
-
+ [backLinkTarget]="['pipelines']">
<div nav fxFlex="100" fxLayout="row" fxLayoutAlign="end center">
<button mat-button
mat-icon-button
@@ -31,19 +30,14 @@
<i class="material-icons">refresh</i>
</button>
</div>
- <div fxFlex="100" fxLayout="column" *ngIf="adapter">
- <sp-basic-header-title-component [title]="adapter.name + ' - Logs'"></sp-basic-header-title-component>
- <div fxFlex="100" fxLayout="column" fxLayoutAlign="center center" *ngIf="!adapterLogs || adapterLogs.length === 0">
- <h5 class="text-center">(no log messages available)</h5>
- </div>
- <div fxFlex="100" fxLayout="column" *ngIf="adapterLogs && adapterLogs.length > 0">
- <div *ngFor="let logEntry of adapterLogs">
- <sp-exception-message [message]="logEntry.errorMessage"
- [messageTimestamp]="logEntry.timestamp"
- *ngIf="logEntry.errorMessage"
- class="mt-10">
- </sp-exception-message>
- </div>
+ <div fxFlex="100" fxLayout="column" *ngIf="activeFunction && contentReady">
+ <div *ngFor="let messagesIn of metrics.messagesIn | keyvalue">
+ <sp-simple-metrics [elementName]="streamNames[messagesIn.key]"
+ lastPublishedLabel="Last consumed message"
+ statusValueLabel="Consumed messages"
+ [lastTimestamp]="messagesIn.value.lastTimestamp"
+ [statusValue]="messagesIn.value.counter">
+ </sp-simple-metrics>
</div>
</div>
diff --git a/ui/src/app/pipelines/components/functions-overview/functions-metrics/functions-metrics.component.ts b/ui/src/app/pipelines/components/functions-overview/functions-metrics/functions-metrics.component.ts
new file mode 100644
index 000000000..ab35a70cc
--- /dev/null
+++ b/ui/src/app/pipelines/components/functions-overview/functions-metrics/functions-metrics.component.ts
@@ -0,0 +1,28 @@
+import { Component, OnInit } from '@angular/core';
+import { AbstractFunctionDetailsDirective } from '../abstract-function-details.directive';
+import { SpMetricsEntry } from '@streampipes/platform-services';
+
+@Component({
+ selector: 'sp-functions-metrics',
+ templateUrl: './functions-metrics.component.html',
+ styleUrls: []
+})
+export class SpFunctionsMetricsComponent extends AbstractFunctionDetailsDirective implements OnInit {
+
+ metrics: SpMetricsEntry;
+
+ ngOnInit(): void {
+ super.onInit();
+ }
+
+ afterFunctionLoaded(): void {
+ this.loadMetrics();
+ }
+
+ loadMetrics() {
+ this.functionsService.getFunctionMetrics(this.activeFunction.functionId.id).subscribe(metrics => {
+ this.metrics = metrics;
+ this.contentReady = true;
+ })
+ }
+}
diff --git a/ui/src/app/pipelines/components/functions-overview/functions-overview.component.html b/ui/src/app/pipelines/components/functions-overview/functions-overview.component.html
new file mode 100644
index 000000000..690663f2a
--- /dev/null
+++ b/ui/src/app/pipelines/components/functions-overview/functions-overview.component.html
@@ -0,0 +1,55 @@
+<!--
+ ~ 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.
+ ~
+ -->
+
+<div fxFlex="100" fxLayout="column" *ngIf="functions.length > 0" style="margin:1px;">
+ <table fxFlex="100" mat-table [dataSource]="dataSource" style="width: 100%;" matSort>
+ <ng-container matColumnDef="name">
+ <th mat-header-cell mat-sort-header *matHeaderCellDef> Name</th>
+ <td mat-cell *matCellDef="let spFunction">
+ <h4 style="margin-bottom:0px;">{{spFunction.id}}:{{spFunction.version}}</h4>
+ </td>
+ </ng-container>
+
+ <ng-container matColumnDef="action">
+ <th mat-header-cell *matHeaderCellDef>
+ <span fxLayoutAlign="end center">Action</span>
+ </th>
+ <td mat-cell *matCellDef="let spFunction">
+ <div fxLayout="row">
+ <span fxFlex fxFlexOrder="1" fxLayout="row" fxLayoutAlign="end center">
+ <button color="accent" mat-button mat-icon-button matTooltip="Show function details"
+ matTooltipPosition="above"
+ (click)="showFunctionDetails(spFunction.id)"><i
+ class="material-icons">search</i>
+ </button>
+ </span>
+ </div>
+ </td>
+ </ng-container>
+
+ <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
+ <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
+
+ </table>
+ <div fxFlex="100" fxLayoutAlign="end end">
+ <mat-paginator [pageSizeOptions]="[5, 10, 25, 100]" [pageSize]="20"></mat-paginator>
+ </div>
+</div>
+<div fxFlex="100" fxLayout="column" fxLayoutAlign="center center" *ngIf="functions.length === 0">
+ <h5>(no functions available)</h5>
+</div>
diff --git a/ui/src/app/connect/components/adapter-details/adapter-details-metrics/adapter-details-metrics.component.scss b/ui/src/app/pipelines/components/functions-overview/functions-overview.component.scss
similarity index 100%
rename from ui/src/app/connect/components/adapter-details/adapter-details-metrics/adapter-details-metrics.component.scss
rename to ui/src/app/pipelines/components/functions-overview/functions-overview.component.scss
diff --git a/ui/src/app/pipelines/components/functions-overview/functions-overview.component.ts b/ui/src/app/pipelines/components/functions-overview/functions-overview.component.ts
new file mode 100644
index 000000000..1637303ec
--- /dev/null
+++ b/ui/src/app/pipelines/components/functions-overview/functions-overview.component.ts
@@ -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.
+ *
+ */
+
+import { Component, Input, OnInit } from '@angular/core';
+import { FunctionId } from '@streampipes/platform-services';
+import { MatTableDataSource } from '@angular/material/table';
+import { Router } from '@angular/router';
+
+@Component({
+ selector: 'sp-functions-overview',
+ templateUrl: './functions-overview.component.html',
+ styleUrls: ['./functions-overview.component.scss']
+})
+export class FunctionsOverviewComponent implements OnInit {
+
+ @Input()
+ functions: FunctionId[] = [];
+
+ dataSource: MatTableDataSource<FunctionId>;
+
+ displayedColumns: string[] = ['name', 'action'];
+
+ constructor(private router: Router) {}
+
+ ngOnInit(): void {
+ this.dataSource = new MatTableDataSource<FunctionId>(this.functions);
+ }
+
+ showFunctionDetails(functionId: string): void {
+ this.router.navigate(['pipelines', 'functions', functionId, 'metrics']);
+ }
+
+}
diff --git a/ui/src/app/pipelines/pipelines.component.html b/ui/src/app/pipelines/pipelines.component.html
index fb08754e6..8d9fa2a64 100644
--- a/ui/src/app/pipelines/pipelines.component.html
+++ b/ui/src/app/pipelines/pipelines.component.html
@@ -52,7 +52,7 @@
</div>
<div fxFlex="100" fxLayout="column">
<div fxLayout="column">
- <sp-basic-header-title-component title="My pipelines"></sp-basic-header-title-component>
+ <sp-basic-header-title-component title="Pipelines"></sp-basic-header-title-component>
<div fxFlex="100" fxLayout="row" fxLayoutAlign="center start">
<sp-basic-inner-panel [showTitle]="false" innerPadding="0" outerMargin="0" fxFlex="90"
[hideToolbar]="true">
@@ -65,15 +65,14 @@
</sp-basic-inner-panel>
</div>
<div fxFlex="100" fxLayout="column" style="margin-top: 20px;">
- <sp-basic-header-title-component title="System-generated pipelines"></sp-basic-header-title-component>
+ <sp-basic-header-title-component title="Functions"></sp-basic-header-title-component>
<div fxFlex="100" fxLayout="row" fxLayoutAlign="center start">
<sp-basic-inner-panel [showTitle]="false" innerPadding="0" outerMargin="0" fxFlex="90"
[hideToolbar]="true">
<div fxFlex="100">
- <pipeline-overview [activeCategoryId]="activeCategoryId" [pipelines]="systemPipelines"
- [pipelineToStart]="systemPipelineToStart"
- (refreshPipelinesEmitter)="refreshPipelines()"
- *ngIf="pipelinesReady"></pipeline-overview>
+ <sp-functions-overview [functions]="functions"
+ *ngIf="functionsReady">
+ </sp-functions-overview>
</div>
</sp-basic-inner-panel>
</div>
diff --git a/ui/src/app/pipelines/pipelines.component.ts b/ui/src/app/pipelines/pipelines.component.ts
index c966ff09a..be344504b 100644
--- a/ui/src/app/pipelines/pipelines.component.ts
+++ b/ui/src/app/pipelines/pipelines.component.ts
@@ -18,16 +18,22 @@
import * as FileSaver from 'file-saver';
import { Component, OnInit } from '@angular/core';
-import { Pipeline, PipelineCategory, PipelineService } from '@streampipes/platform-services';
+import {
+ FunctionId,
+ FunctionsService,
+ Pipeline,
+ PipelineCategory,
+ PipelineService
+} from '@streampipes/platform-services';
import { DialogRef, DialogService, PanelType, SpBreadcrumbService } from '@streampipes/shared-ui';
import { ImportPipelineDialogComponent } from './dialog/import-pipeline/import-pipeline-dialog.component';
import { StartAllPipelinesDialogComponent } from './dialog/start-all-pipelines/start-all-pipelines-dialog.component';
import { PipelineCategoriesDialogComponent } from './dialog/pipeline-categories/pipeline-categories-dialog.component';
-import { zip } from 'rxjs';
import { ActivatedRoute, Router } from '@angular/router';
import { AuthService } from '../services/auth.service';
import { UserPrivilege } from '../_enums/user-privilege.enum';
import { SpPipelineRoutes } from './pipelines.routes';
+import { UserRole } from '../_enums/user-role.enum';
@Component({
selector: 'pipelines',
@@ -54,11 +60,16 @@ export class PipelinesComponent implements OnInit {
selectedCategoryIndex = 0;
hasPipelineWritePrivileges = false;
+ functions: FunctionId[] = [];
+ functionsReady = false;
+ isAdminRole = false;
+
constructor(private pipelineService: PipelineService,
private dialogService: DialogService,
private activatedRoute: ActivatedRoute,
private authService: AuthService,
private router: Router,
+ private functionsService: FunctionsService,
private breadcrumbService: SpBreadcrumbService) {
this.pipelineCategories = [];
this.starting = false;
@@ -69,6 +80,7 @@ export class PipelinesComponent implements OnInit {
this.breadcrumbService.updateBreadcrumb(this.breadcrumbService.getRootLink(SpPipelineRoutes.BASE));
this.authService.user$.subscribe(user => {
this.hasPipelineWritePrivileges = this.authService.hasRole(UserPrivilege.PRIVILEGE_WRITE_PIPELINE);
+ this.isAdminRole = this.authService.hasRole(UserRole.ROLE_ADMIN);
});
this.activatedRoute.queryParams.subscribe(params => {
if (params['pipeline']) {
@@ -76,11 +88,12 @@ export class PipelinesComponent implements OnInit {
}
this.getPipelineCategories();
this.getPipelines();
+ this.getFunctions()
});
}
setSelectedTab(index) {
- this.activeCategoryId = index === 0 ? undefined : this.pipelineCategories[index - 1]._id;
+ this.activeCategoryId = index === 0 ? undefined : this.pipelineCategories[index - 1]._id;
}
exportPipelines() {
@@ -88,37 +101,38 @@ export class PipelinesComponent implements OnInit {
FileSaver.saveAs(blob, 'pipelines.json');
}
+ getFunctions() {
+ this.functionsService.getActiveFunctions().subscribe(functions => {
+ this.functions = functions.map(f => f.functionId);
+ console.log(this.functions);
+ this.functionsReady = true;
+ })
+ }
+
getPipelines() {
this.pipelines = [];
- zip(this.pipelineService.getOwnPipelines(), this.pipelineService.getSystemPipelines()).subscribe(allPipelines => {
- this.pipelines = allPipelines[0];
- this.systemPipelines = allPipelines[1];
- this.checkForImmediateStart(allPipelines);
+ this.pipelineService.getOwnPipelines().subscribe(pipelines => {
+ this.pipelines = pipelines;
+ this.checkForImmediateStart(pipelines);
this.pipelinesReady = true;
});
}
- checkForImmediateStart(allPipelines: Pipeline[][]) {
+ checkForImmediateStart(pipelines: Pipeline[]) {
this.pipelineToStart = undefined;
- allPipelines.forEach((pipelines, index) => {
- pipelines.forEach(pipeline => {
- if (pipeline._id === this.pipelineIdToStart) {
- if (index === 0) {
- this.pipelineToStart = pipeline;
- } else {
- this.systemPipelineToStart = pipeline;
- }
- }
- });
+ pipelines.forEach(pipeline => {
+ if (pipeline._id === this.pipelineIdToStart) {
+ this.pipelineToStart = pipeline;
+ }
});
this.pipelineIdToStart = undefined;
}
getPipelineCategories() {
this.pipelineService.getPipelineCategories()
- .subscribe(pipelineCategories => {
- this.pipelineCategories = pipelineCategories;
- });
+ .subscribe(pipelineCategories => {
+ this.pipelineCategories = pipelineCategories;
+ });
}
activeClass(pipeline) {
diff --git a/ui/src/app/pipelines/pipelines.module.ts b/ui/src/app/pipelines/pipelines.module.ts
index 1695496ad..ae655b985 100644
--- a/ui/src/app/pipelines/pipelines.module.ts
+++ b/ui/src/app/pipelines/pipelines.module.ts
@@ -48,6 +48,9 @@ import { SpPipelineDetailsOverviewComponent } from '../pipeline-details/componen
import { PipelineMonitoringComponent } from '../pipeline-details/components/monitoring/pipeline-monitoring.component';
import { QuickEditComponent } from '../pipeline-details/components/edit/quickedit.component';
import { PipelineLogsComponent } from '../pipeline-details/components/pipeline-logs/pipeline-logs.component';
+import { FunctionsOverviewComponent } from './components/functions-overview/functions-overview.component';
+import { SpFunctionsMetricsComponent } from './components/functions-overview/functions-metrics/functions-metrics.component';
+import { SpFunctionsLogsComponent } from './components/functions-overview/functions-logs/functions-logs.component';
@NgModule({
imports: [
@@ -73,6 +76,14 @@ import { PipelineLogsComponent } from '../pipeline-details/components/pipeline-l
path: '',
component: PipelinesComponent
},
+ {
+ path: 'functions/:functionId/metrics',
+ component: SpFunctionsMetricsComponent
+ },
+ {
+ path: 'functions/:functionId/logs',
+ component: SpFunctionsLogsComponent
+ },
{
path: 'details/:pipelineId',
children: [
@@ -113,6 +124,7 @@ import { PipelineLogsComponent } from '../pipeline-details/components/pipeline-l
],
declarations: [
DeletePipelineDialogComponent,
+ FunctionsOverviewComponent,
ImportPipelineDialogComponent,
PipelinesComponent,
PipelineCategoriesDialogComponent,
@@ -121,7 +133,9 @@ import { PipelineLogsComponent } from '../pipeline-details/components/pipeline-l
PipelineStatusDialogComponent,
StartAllPipelinesDialogComponent,
PipelineInCategoryPipe,
- CategoryAlreadyInPipelinePipe
+ CategoryAlreadyInPipelinePipe,
+ SpFunctionsMetricsComponent,
+ SpFunctionsLogsComponent
],
providers: [
PipelineOperationsService,
diff --git a/ui/src/app/pipelines/pipelines.routes.ts b/ui/src/app/pipelines/pipelines.routes.ts
index 5b4ccc7fb..c3707b8a8 100644
--- a/ui/src/app/pipelines/pipelines.routes.ts
+++ b/ui/src/app/pipelines/pipelines.routes.ts
@@ -20,6 +20,6 @@ import { SpBreadcrumbItem, } from '@streampipes/shared-ui';
export class SpPipelineRoutes {
- static BASE: SpBreadcrumbItem = {label: 'Pipelines', link: ['pipelines']};
+ static BASE: SpBreadcrumbItem = {label: 'Pipelines & Functions', link: ['pipelines']};
}