@@ -50,10 +50,14 @@ public synchronized void initialize(Configuration configuration) throws IOExcept
50
50
// 获取用户配置的 POSIX extension 特性目录
51
51
String cacheDirPath = configuration .get (
52
52
CosNConfigKeys .COSN_POSIX_EXTENSION_TMP_DIR , CosNConfigKeys .DEFAULT_POSIX_EXTENSION_TMP_DIR );
53
- this .cacheDir = new File (cacheDirPath );
53
+ // 正式构建 MappedFactory 用于后续创建本地缓存文件
54
+ boolean deleteOnExit = configuration .getBoolean (
55
+ CosNConfigKeys .COSN_MAPDISK_DELETEONEXIT_ENABLED , CosNConfigKeys .DEFAULT_COSN_MAPDISK_DELETEONEXIT_ENABLED );
56
+ this .mappedBufferFactory = new CosNRandomAccessMappedBufferFactory (cacheDirPath , deleteOnExit );
54
57
58
+ this .cacheDir = new File (cacheDirPath );
55
59
// 检查当前目录空间是否足够
56
- long usableSpace = this .cacheDir .getUsableSpace ();
60
+ long usableSpace = this .cacheDir .getParentFile (). getUsableSpace ();
57
61
long quotaSize = configuration .getLong (CosNConfigKeys .COSN_POSIX_EXTENSION_TMP_DIR_QUOTA ,
58
62
CosNConfigKeys .DEFAULT_COSN_POSIX_EXTENSION_TMP_DIR_QUOTA );
59
63
Preconditions .checkArgument (quotaSize <= usableSpace ,
@@ -75,11 +79,6 @@ public synchronized void initialize(Configuration configuration) throws IOExcept
75
79
this .highWaterMarkRemainingSpace = (long ) (quotaSize * (1 - highWaterMark ));
76
80
this .lowWaterMarkRemainingSpace = (long ) (quotaSize * (1 - lowWaterMark ));
77
81
78
- // 正式构建 MappedFactory 用于后续创建本地缓存文件
79
- boolean deleteOnExit = configuration .getBoolean (
80
- CosNConfigKeys .COSN_MAPDISK_DELETEONEXIT_ENABLED , CosNConfigKeys .DEFAULT_COSN_MAPDISK_DELETEONEXIT_ENABLED );
81
- this .mappedBufferFactory = new CosNRandomAccessMappedBufferFactory (cacheDirPath , deleteOnExit );
82
-
83
82
this .referCount .incrementAndGet ();
84
83
this .isInitialized .set (true );
85
84
}
0 commit comments