TarsCloud / TarsJava

Java language framework rpc source code implementation
Other
401 stars 169 forks source link

tarsnodes.dat存储疑惑 #195

Open walkertest opened 2 years ago

walkertest commented 2 years ago

当有些地方不设置datapath,比如一些sdk(兼容非tars服务)的时候,tarsnodes.dat的存储路径会比较怪.

例子:

            URL url  = Loader.getResource("", true);
            String path=url.getFile();
            File f = new File(path, Constants.SERVER_NODE_CACHE_FILENAME);
            String parentPath = f.getParentFile().getPath();
            String filePath = f.getAbsolutePath();

            log.info("URL_DATA_PATH:{} parentPath:{} filePath:{}",
                    path, parentPath, filePath);

输出结果:

URL_DATA_PATH:file:/data/app/taf/tafnode/data/TAFJAVADEMO.HelloServer/bin/HelloServer.jar!/BOOT-INF/classes!/ parentPath:file:/data/app/taf/tafnode/data/TAFJAVADEMO.
HelloServer/bin/HelloServer.jar!/BOOT-INF/classes! filePath:/data/app/taf/app_log/file:/data/app/taf/tafnode/data/TAFJAVADEMO.HelloServer/bin/HelloServer.jar!/BOOT-INF/cla
sses!/tafnodes.dat

疑问:

  1. 存储的绝对路径上带了一个前缀:/data/app/taf/app_log/file:, 貌似是logPath,这个是怎么造成的?
  2. 怎么避免这样的多个存储路径问题. 并且这个路径会有转义字符. 多个路径会导致缓存文件不好管理以及清理.