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 2025/01/10 04:37:59 UTC
(streampipes) branch update-asset-directory-env created (now 244c3a8eeb)
This is an automated email from the ASF dual-hosted git repository.
riemer pushed a change to branch update-asset-directory-env
in repository https://gitbox.apache.org/repos/asf/streampipes.git
at 244c3a8eeb feat: Update asset and file directories upon restart
This branch includes the following new commits:
new 244c3a8eeb feat: Update asset and file directories upon restart
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: feat: Update asset and file directories upon restart
Posted by ri...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
riemer pushed a commit to branch update-asset-directory-env
in repository https://gitbox.apache.org/repos/asf/streampipes.git
commit 244c3a8eeb5135aba1c4c098adb62461752b80f7
Author: Dominik Riemer <do...@gmail.com>
AuthorDate: Fri Jan 10 05:37:42 2025 +0100
feat: Update asset and file directories upon restart
---
.../configuration/DefaultSpCoreConfiguration.java | 4 +--
.../manager/setup/StreamPipesEnvChecker.java | 31 +++++++++++++++++-----
2 files changed, 27 insertions(+), 8 deletions(-)
diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/configuration/DefaultSpCoreConfiguration.java b/streampipes-model/src/main/java/org/apache/streampipes/model/configuration/DefaultSpCoreConfiguration.java
index b669b3e4b7..0514006380 100644
--- a/streampipes-model/src/main/java/org/apache/streampipes/model/configuration/DefaultSpCoreConfiguration.java
+++ b/streampipes-model/src/main/java/org/apache/streampipes/model/configuration/DefaultSpCoreConfiguration.java
@@ -40,12 +40,12 @@ public class DefaultSpCoreConfiguration {
return coreCfg;
}
- private String makeAssetLocation() {
+ public String makeAssetLocation() {
return makeStreamPipesHomeLocation()
+ "assets";
}
- private String makeFileLocation() {
+ public String makeFileLocation() {
return makeStreamPipesHomeLocation()
+ "files";
}
diff --git a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/setup/StreamPipesEnvChecker.java b/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/setup/StreamPipesEnvChecker.java
index 70e5a8aa59..0062419eb4 100644
--- a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/setup/StreamPipesEnvChecker.java
+++ b/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/setup/StreamPipesEnvChecker.java
@@ -20,10 +20,10 @@ package org.apache.streampipes.manager.setup;
import org.apache.streampipes.commons.environment.Environment;
import org.apache.streampipes.commons.environment.Environments;
+import org.apache.streampipes.model.configuration.DefaultSpCoreConfiguration;
import org.apache.streampipes.model.configuration.JwtSigningMode;
import org.apache.streampipes.model.configuration.LocalAuthConfig;
import org.apache.streampipes.model.configuration.SpCoreConfiguration;
-import org.apache.streampipes.storage.api.ISpCoreConfigurationStorage;
import org.apache.streampipes.storage.management.StorageDispatcher;
import org.slf4j.Logger;
@@ -37,7 +37,6 @@ public class StreamPipesEnvChecker {
private static final Logger LOG = LoggerFactory.getLogger(StreamPipesEnvChecker.class);
- private ISpCoreConfigurationStorage configStorage;
private SpCoreConfiguration coreConfig;
private final Environment env;
@@ -47,7 +46,7 @@ public class StreamPipesEnvChecker {
}
public void updateEnvironmentVariables() {
- this.configStorage = StorageDispatcher
+ var configStorage = StorageDispatcher
.INSTANCE
.getNoSqlStore()
.getSpCoreConfigurationStorage();
@@ -56,11 +55,29 @@ public class StreamPipesEnvChecker {
this.coreConfig = configStorage.get();
LOG.info("Checking and updating environment variables...");
- updateJwtSettings();
+ var shouldUpdateJwtConfig = updateJwtSettings();
+ var shouldUpdateDirectoryConfig = updateDirectorySettings();
+
+ if (shouldUpdateJwtConfig || shouldUpdateDirectoryConfig) {
+ configStorage.updateElement(coreConfig);
+ }
}
}
- private void updateJwtSettings() {
+ private boolean updateDirectorySettings() {
+ if (env.getCoreAssetBaseDir().exists()) {
+ LOG.info("Using asset directory provided by environment variable {}",
+ env.getCoreAssetBaseDir().getEnvVariableName());
+ var defaultCoreConfig = new DefaultSpCoreConfiguration();
+ coreConfig.setFilesDir(defaultCoreConfig.makeFileLocation());
+ coreConfig.setAssetDir(defaultCoreConfig.makeAssetLocation());
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ private boolean updateJwtSettings() {
LocalAuthConfig localAuthConfig = coreConfig.getLocalAuthConfig();
boolean incompleteConfig = false;
var signingMode = env.getJwtSigningMode();
@@ -108,7 +125,9 @@ public class StreamPipesEnvChecker {
if (!incompleteConfig) {
LOG.info("Updating local auth config with signing mode {}", localAuthConfig.getJwtSigningMode().name());
coreConfig.setLocalAuthConfig(localAuthConfig);
- configStorage.updateElement(coreConfig);
+ return true;
+ } else {
+ return false;
}
}