You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2020/03/11 08:43:40 UTC
[skywalking] 01/02: Temp commit
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch vault-support
in repository https://gitbox.apache.org/repos/asf/skywalking.git
commit 157149317871a73e876ea50445f77cb4b7c37a56
Author: Wu Sheng <wu...@foxmail.com>
AuthorDate: Wed Mar 11 13:47:17 2020 +0800
Temp commit
---
.../library/util/MultipleFilesChangeMonitor.java | 8 ++++++--
.../StorageModuleElasticsearchConfig.java | 6 +++++-
.../StorageModuleElasticsearchProvider.java | 24 ++++++++++++++++++++++
3 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/oap-server/server-library/library-util/src/main/java/org/apache/skywalking/oap/server/library/util/MultipleFilesChangeMonitor.java b/oap-server/server-library/library-util/src/main/java/org/apache/skywalking/oap/server/library/util/MultipleFilesChangeMonitor.java
index 8b4e2c4..0d49516 100644
--- a/oap-server/server-library/library-util/src/main/java/org/apache/skywalking/oap/server/library/util/MultipleFilesChangeMonitor.java
+++ b/oap-server/server-library/library-util/src/main/java/org/apache/skywalking/oap/server/library/util/MultipleFilesChangeMonitor.java
@@ -100,7 +100,11 @@ public class MultipleFilesChangeMonitor {
watchedFiles.forEach(file -> {
contents.add(file.fileContent);
});
- notifier.filesChanged(contents);
+ try {
+ notifier.filesChanged(contents);
+ } catch (Exception e) {
+ log.error("Files=" + this + " notification process failure.", e);
+ }
}
}
@@ -170,7 +174,7 @@ public class MultipleFilesChangeMonitor {
*
* @param readableContents include the new contents. NULL if the file doesn't exist.
*/
- void filesChanged(List<byte[]> readableContents);
+ void filesChanged(List<byte[]> readableContents) throws Exception;
}
/**
diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/StorageModuleElasticsearchConfig.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/StorageModuleElasticsearchConfig.java
index 23a7237..18c4ca5 100644
--- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/StorageModuleElasticsearchConfig.java
+++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/StorageModuleElasticsearchConfig.java
@@ -49,6 +49,11 @@ public class StorageModuleElasticsearchConfig extends ModuleConfig {
private String user;
@Setter
private String password;
+ /**
+ * Secrets management file includes the username, password, which are managed by 3rd party tool.
+ */
+ @Getter
+ private String secretsManagementFile;
@Getter
@Setter
String trustStorePath;
@@ -75,7 +80,6 @@ public class StorageModuleElasticsearchConfig extends ModuleConfig {
*
* Same as {@link #enablePackedDownsampling} this config doesn't affects month level data. Because usually, no one
* keeps the observability data in several months.
- *
*/
@Getter
private int dayStep = 1;
diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/StorageModuleElasticsearchProvider.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/StorageModuleElasticsearchProvider.java
index 6448a9a..eb7e454 100644
--- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/StorageModuleElasticsearchProvider.java
+++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/StorageModuleElasticsearchProvider.java
@@ -18,6 +18,7 @@
package org.apache.skywalking.oap.server.storage.plugin.elasticsearch;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
@@ -26,6 +27,7 @@ import java.security.cert.CertificateException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.skywalking.apm.util.StringUtil;
import org.apache.skywalking.oap.server.core.Const;
@@ -60,6 +62,7 @@ import org.apache.skywalking.oap.server.library.module.ModuleDefine;
import org.apache.skywalking.oap.server.library.module.ModuleProvider;
import org.apache.skywalking.oap.server.library.module.ModuleStartException;
import org.apache.skywalking.oap.server.library.module.ServiceNotProvidedException;
+import org.apache.skywalking.oap.server.library.util.MultipleFilesChangeMonitor;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.BatchProcessEsDAO;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.HistoryDeleteEsDAO;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.StorageEsDAO;
@@ -117,6 +120,27 @@ public class StorageModuleElasticsearchProvider extends ModuleProvider {
if (config.getDayStep() > 1) {
TimeSeriesUtils.setDAY_STEP(config.getDayStep());
}
+
+ if (!StringUtil.isEmpty(config.getSecretsManagementFile())) {
+ MultipleFilesChangeMonitor monitor = new MultipleFilesChangeMonitor(
+ 10, new MultipleFilesChangeMonitor.FilesChangedNotifier() {
+ @Override
+ public void filesChanged(final List<byte[]> readableContents) throws IOException {
+ final byte[] secretsFileContent = readableContents.get(0);
+ if (secretsFileContent == null) {
+ return;
+ }
+ Properties userAndPass = new Properties();
+ userAndPass.load(new ByteArrayInputStream(secretsFileContent));
+ userAndPass.getProperty("username")
+ }
+ }, config.getSecretsManagementFile());
+ /**
+ * By leveraging the sync update check feature when startup.
+ */
+ monitor.start();
+ }
+
elasticSearchClient = new ElasticSearchClient(
config.getClusterNodes(), config.getProtocol(), config.getTrustStorePath(), config
.getTrustStorePass(), config.getUser(), config.getPassword(),