Selaa lähdekoodia

鉴于 oss-store 所部署的节点可能由于多网卡导致每次获取的 IP 地址不固定, 因此直接在 spring 配置文件中指定 store 节点的地址, 保证地址的 constant

reghao 2 vuotta sitten
vanhempi
commit
a224a5037c

+ 1 - 1
oss-console/src/main/java/cn/reghao/oss/console/app/service/OssStoreService.java

@@ -45,6 +45,6 @@ public class OssStoreService {
         String domain = storeNode.getDomain();
         String secretKey = storeNode.getSecretKey();
         String referer = storeNode.getReferer();
-        return new StoreProperties(nodeAddr, domain, secretKey, referer);
+        return new StoreProperties(domain, secretKey, referer);
     }
 }

+ 1 - 1
oss-console/src/main/java/cn/reghao/oss/console/app/service/StoreNodeService.java

@@ -74,7 +74,7 @@ public class StoreNodeService {
         storeNode.setEnabled(true);
         storeNodeRepository.save(storeNode);
 
-        StoreProperties storeProperties = new StoreProperties(nodeAddr, domain, secretKey, referer);
+        StoreProperties storeProperties = new StoreProperties(domain, secretKey, referer);
         StoreService storeService = rpcService.getStoreService(storeNode);
         storeService.updateStoreProperties(storeProperties);
         return Result.success();

+ 1 - 0
oss-store/bin/oss.yml

@@ -8,5 +8,6 @@ spring:
     password: Dev@123456
 oss:
   consoleEndpoint: http://ossconsole.reghao.cn
+  host: 192.168.0.78
   diskDirs:
     - /opt/oss/disk/13f654c8-af87-4710-aac9-7aa086c99aec/

+ 1 - 0
oss-store/src/main/java/cn/reghao/oss/store/config/OssProperties.java

@@ -16,6 +16,7 @@ import java.util.List;
 @Component
 @ConfigurationProperties(prefix = "oss")
 public class OssProperties {
+    private String host;
     private String consoleEndpoint;
     private List<String> diskDirs;
 }

+ 2 - 2
oss-store/src/main/java/cn/reghao/oss/store/config/SpringProperties.java

@@ -22,8 +22,8 @@ public class SpringProperties {
         this.ossProperties = ossProperties;
     }
 
-    public String getConsoleEndpoint() {
-        return ossProperties.getConsoleEndpoint();
+    public String getHost() {
+        return ossProperties.getHost();
     }
 
     public int getHttpPort() {

+ 7 - 1
oss-store/src/main/java/cn/reghao/oss/store/service/StoreLocalCache.java

@@ -2,6 +2,7 @@ package cn.reghao.oss.store.service;
 
 import cn.reghao.oss.store.api.dto.ObjectChannel;
 import cn.reghao.oss.store.api.dto.StoreProperties;
+import cn.reghao.oss.store.config.SpringProperties;
 import org.springframework.stereotype.Service;
 
 import java.util.HashMap;
@@ -17,6 +18,11 @@ public class StoreLocalCache {
     private StoreProperties storeProperties;
     private final Map<String, ObjectChannel> prefixMap = new HashMap<>();
     private final Map<Integer, ObjectChannel> channelIdMap = new HashMap<>();
+    private final SpringProperties springProperties;
+
+    public StoreLocalCache(SpringProperties springProperties) {
+        this.springProperties = springProperties;
+    }
 
     public void initOssStore(StoreProperties storeProperties, List<ObjectChannel> list) {
         this.storeProperties = storeProperties;
@@ -33,7 +39,7 @@ public class StoreLocalCache {
     }
 
     public String getHost() {
-        return storeProperties != null ? storeProperties.getHost() : null;
+        return springProperties.getHost();
     }
 
     public String getDomain() {

+ 0 - 1
store-api/src/main/java/cn/reghao/oss/store/api/dto/StoreProperties.java

@@ -14,7 +14,6 @@ import java.io.Serializable;
 public class StoreProperties implements Serializable {
     private static final long serialVersionUID = 1L;
 
-    private String host;
     private String domain;
     private String secretKey;
     private String referer;