You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@streampipes.apache.org by "dominikriemer (via GitHub)" <gi...@apache.org> on 2023/10/30 07:04:50 UTC

[PR] Improve startup behaviour

dominikriemer opened a new pull request, #2105:
URL: https://github.com/apache/streampipes/pull/2105

   <!--
     ~ 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.
     ~
     -->
     
     <!--
   Thanks for contributing! Here are some tips you can follow to help us incorporate your contribution quickly and easily:
   1. If this is your first time, please read our contributor guidelines:
       - https://streampipes.apache.org/getinvolved.html
       - https://cwiki.apache.org/confluence/display/STREAMPIPES/Getting+Started
   2. Make sure the PR title is formatted like: `[#<GitHub issue id>] PR title ...`
   3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., `[WIP][#<GitHub issue id>] PR title ...`.
   4. Please write your PR title to summarize what this PR proposes/fixes.
   5. Link the PR to the corresponding GitHub issue (if present) in the `Development` section in the right menu bar. 
   6. Be sure to keep the PR description updated to reflect all changes.
   7. If possible, provide a concise example to reproduce the issue for a faster review.
   8. Make sure tests pass via `mvn clean install`.
   9. (Optional) If the contribution is large, please file an Apache ICLA
       - http://apache.org/licenses/icla.pdf
   -->
   
   ### Purpose
   <!--
   Please clarify what changes you are proposing and describe how those changes will address the issue.
   Furthermore, describe potential consequences the changes might have.
   -->
   
   * Improve the lifecycle of various requests during the initialization of core and extensions
   * Introduce states for extension services REGISTERED, MIGRATING, HEALTHY, UNHEALTHY
   * Introduce states for core INSTALLING, MIGRATING; READY
   * Add logic to improve the order of initialization actions: Start core, register extensions, perform core migrations, perform extenion migrations
   
   ### Remarks
   <!--
   Is there anything left we need to pay attention on?
   Are there some references that might be important? E.g. links to Confluence, or discussions
   on the mailing list or GitHub.
   -->
   PR introduces (a) breaking change(s): <yes/no>
   
   PR introduces (a) deprecation(s): <yes/no>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@streampipes.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Improve startup behaviour

Posted by "bossenti (via GitHub)" <gi...@apache.org>.
bossenti commented on code in PR #2105:
URL: https://github.com/apache/streampipes/pull/2105#discussion_r1379643925


##########
streampipes-service-extensions/src/main/java/org/apache/streampipes/service/extensions/CoreRequestSubmitter.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.service.extensions;
+
+import org.apache.streampipes.commons.exceptions.SpRuntimeException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.concurrent.TimeUnit;
+import java.util.function.Supplier;
+
+public class CoreRequestSubmitter {
+
+  private static final Logger LOG = LoggerFactory.getLogger(CoreRequestSubmitter.class);
+
+  private static final int RETRY_INTERVAL_SECONDS = 3;
+
+  public void submitRepeatedRequest(Supplier<Boolean> request,
+                                    Supplier<String> successMessage,
+                                    Supplier<String> failureMessage) {

Review Comment:
   Can't we pass the messages as simple strings?



##########
streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/migration/AdapterDescriptionMigration093.java:
##########
@@ -0,0 +1,73 @@
+/*
+ * 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.manager.migration;
+
+import org.apache.streampipes.commons.exceptions.SepaParseException;
+import org.apache.streampipes.manager.endpoint.HttpJsonParser;
+import org.apache.streampipes.manager.operations.Operations;
+import org.apache.streampipes.manager.util.AuthTokenUtils;
+import org.apache.streampipes.model.extensions.svcdiscovery.SpServiceRegistration;
+import org.apache.streampipes.model.extensions.svcdiscovery.SpServiceTagPrefix;
+import org.apache.streampipes.storage.api.IAdapterStorage;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.net.URI;
+
+import static org.apache.streampipes.manager.migration.MigrationUtils.getRequestUrl;
+
+public class AdapterDescriptionMigration093 extends AbstractMigrationManager {
+
+  private static final Logger LOG = LoggerFactory.getLogger(AdapterDescriptionMigration093.class);
+
+  private final IAdapterStorage adapterDescriptionStorage;
+
+  public AdapterDescriptionMigration093(IAdapterStorage adapterDescriptionStorage) {
+    this.adapterDescriptionStorage = adapterDescriptionStorage;
+  }
+
+  public void reinstallAdapters(SpServiceRegistration extensionsServiceConfig) {
+    var migrationProvider = AdapterDescriptionMigration093Provider.INSTANCE;
+    if (migrationProvider.hasAppIdsToReinstall()) {
+      var appIdsToReinstall = migrationProvider.getAppIdsToReinstall();
+      var serviceUrl = extensionsServiceConfig.getServiceUrl();
+      extensionsServiceConfig.getTags()
+          .stream()
+          .filter(tag -> tag.getPrefix() == SpServiceTagPrefix.ADAPTER)
+          .filter(tag -> appIdsToReinstall.contains(tag.getValue()))
+          .forEach(tag -> {
+            var appId = tag.getValue();
+            try {
+              if (adapterDescriptionStorage.getAdaptersByAppId(appId).isEmpty()) {
+                var requestUrl = getRequestUrl(SpServiceTagPrefix.ADAPTER, appId, serviceUrl);
+                var entityPayload = HttpJsonParser.getContentFromUrl(URI.create(requestUrl));
+                Operations.verifyAndAddElement(

Review Comment:
   Does this then also include assets (icons, etc.)? If so, this would close #2096 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@streampipes.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Improve startup behaviour

Posted by "dominikriemer (via GitHub)" <gi...@apache.org>.
dominikriemer merged PR #2105:
URL: https://github.com/apache/streampipes/pull/2105


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@streampipes.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org