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 2023/12/13 21:08:39 UTC
(streampipes) branch fix-serialization-problems created (now f9b0d0bd3)
This is an automated email from the ASF dual-hosted git repository.
riemer pushed a change to branch fix-serialization-problems
in repository https://gitbox.apache.org/repos/asf/streampipes.git
at f9b0d0bd3 fix: Fix serialization problems with migration
This branch includes the following new commits:
new f9b0d0bd3 fix: Fix serialization problems with migration
The 1 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.
(streampipes) 01/01: fix: Fix serialization problems with migration
Posted by ri...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
riemer pushed a commit to branch fix-serialization-problems
in repository https://gitbox.apache.org/repos/asf/streampipes.git
commit f9b0d0bd3c22c1556d0e7d7deb1db48c6004546c
Author: Dominik Riemer <do...@gmail.com>
AuthorDate: Wed Dec 13 22:08:25 2023 +0100
fix: Fix serialization problems with migration
---
.../management/AdapterMasterManagement.java | 7 ++++-
.../model/migration/MigrationResult.java | 8 +++--
.../migration/AbstractMigrationManager.java | 3 +-
.../shared/serializer/SpringJacksonSerializer.java | 34 ----------------------
.../extensions/ExtensionsModelSubmitter.java | 3 +-
5 files changed, 14 insertions(+), 41 deletions(-)
diff --git a/streampipes-connect-management/src/main/java/org/apache/streampipes/connect/management/management/AdapterMasterManagement.java b/streampipes-connect-management/src/main/java/org/apache/streampipes/connect/management/management/AdapterMasterManagement.java
index 8df3721de..ec8790902 100644
--- a/streampipes-connect-management/src/main/java/org/apache/streampipes/connect/management/management/AdapterMasterManagement.java
+++ b/streampipes-connect-management/src/main/java/org/apache/streampipes/connect/management/management/AdapterMasterManagement.java
@@ -39,6 +39,7 @@ import org.slf4j.LoggerFactory;
import java.net.URISyntaxException;
import java.util.List;
+import java.util.NoSuchElementException;
/**
* This class is responsible for managing all the adapter instances which are executed on worker nodes
@@ -150,7 +151,11 @@ public class AdapterMasterManagement {
// remove the adapter from the metrics manager so that
// no metrics for this adapter are exposed anymore
- adapterMetrics.remove(ad.getElementId(), ad.getName());
+ try {
+ adapterMetrics.remove(ad.getElementId(), ad.getName());
+ } catch (NoSuchElementException e) {
+ LOG.error("Could not remove adapter metrics for adapter {}", ad.getName());
+ }
}
public void startStreamAdapter(String elementId) throws AdapterException {
diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/migration/MigrationResult.java b/streampipes-model/src/main/java/org/apache/streampipes/model/migration/MigrationResult.java
index 805dc65ea..f25557e76 100644
--- a/streampipes-model/src/main/java/org/apache/streampipes/model/migration/MigrationResult.java
+++ b/streampipes-model/src/main/java/org/apache/streampipes/model/migration/MigrationResult.java
@@ -18,6 +18,8 @@
package org.apache.streampipes.model.migration;
+import org.apache.streampipes.model.base.NamedStreamPipesEntity;
+
/**
* Models the outcome of a migration.
* @param success whether the migration was successfully or not.
@@ -25,13 +27,13 @@ package org.apache.streampipes.model.migration;
* @param message message that describes the outcome of the migration
* @param <T> type of the migration element
*/
-public record MigrationResult<T> (boolean success, T element, String message){
+public record MigrationResult<T extends NamedStreamPipesEntity> (boolean success, T element, String message){
- public static <T> MigrationResult<T> failure(T element, String message) {
+ public static <T extends NamedStreamPipesEntity> MigrationResult<T> failure(T element, String message) {
return new MigrationResult<>(false, element, message);
}
- public static <T> MigrationResult<T> success(T element) {
+ public static <T extends NamedStreamPipesEntity> MigrationResult<T> success(T element) {
return new MigrationResult<>(true, element, "SUCCESS");
}
}
diff --git a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/migration/AbstractMigrationManager.java b/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/migration/AbstractMigrationManager.java
index 3641f0b7c..ce5ede351 100644
--- a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/migration/AbstractMigrationManager.java
+++ b/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/migration/AbstractMigrationManager.java
@@ -80,9 +80,10 @@ public abstract class AbstractMigrationManager {
TypeReference<MigrationResult<T>> typeReference = new TypeReference<>() {
};
+ String migrationResponseString = migrationResponse.returnContent().asString();
return JacksonSerializer
.getObjectMapper()
- .readValue(migrationResponse.returnContent().asString(), typeReference);
+ .readValue(migrationResponseString, typeReference);
} catch (JsonProcessingException e) {
LOG.error(
"Migration of pipeline element failed before sending to the extensions service, "
diff --git a/streampipes-rest-shared/src/main/java/org/apache/streampipes/rest/shared/serializer/SpringJacksonSerializer.java b/streampipes-rest-shared/src/main/java/org/apache/streampipes/rest/shared/serializer/SpringJacksonSerializer.java
deleted file mode 100644
index 164309c3c..000000000
--- a/streampipes-rest-shared/src/main/java/org/apache/streampipes/rest/shared/serializer/SpringJacksonSerializer.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.shared.serializer;
-
-import org.apache.streampipes.serializers.json.JacksonSerializer;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Primary;
-
-public class SpringJacksonSerializer {
-
- @Bean
- @Primary
- public ObjectMapper objectMapper() {
- return JacksonSerializer.getObjectMapper();
- }
-}
diff --git a/streampipes-service-extensions/src/main/java/org/apache/streampipes/service/extensions/ExtensionsModelSubmitter.java b/streampipes-service-extensions/src/main/java/org/apache/streampipes/service/extensions/ExtensionsModelSubmitter.java
index 72557f6b8..ff7c72152 100644
--- a/streampipes-service-extensions/src/main/java/org/apache/streampipes/service/extensions/ExtensionsModelSubmitter.java
+++ b/streampipes-service-extensions/src/main/java/org/apache/streampipes/service/extensions/ExtensionsModelSubmitter.java
@@ -25,7 +25,6 @@ import org.apache.streampipes.extensions.management.model.SpServiceDefinition;
import org.apache.streampipes.model.extensions.svcdiscovery.SpServiceRegistration;
import org.apache.streampipes.model.extensions.svcdiscovery.SpServiceTag;
import org.apache.streampipes.rest.extensions.WelcomePage;
-import org.apache.streampipes.rest.shared.serializer.SpringJacksonSerializer;
import org.apache.streampipes.service.base.rest.ServiceHealthResource;
import org.apache.streampipes.service.extensions.function.StreamPipesFunctionHandler;
import org.apache.streampipes.service.extensions.security.WebSecurityConfig;
@@ -41,7 +40,7 @@ import java.util.List;
@Configuration
@EnableAutoConfiguration
-@Import({WebSecurityConfig.class, WelcomePage.class, ServiceHealthResource.class, SpringJacksonSerializer.class})
+@Import({WebSecurityConfig.class, WelcomePage.class, ServiceHealthResource.class})
@ComponentScan({"org.apache.streampipes.rest.extensions.*", "org.apache.streampipes.service.base.rest.*"})
public abstract class ExtensionsModelSubmitter extends StreamPipesExtensionsServiceBase {