Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.

Commit bdfae36

Browse files
rui-mophilo-he
authored andcommitted
Ignore SSM work dir and trigger fetch operation when a file is moved to covered dir (#2067)
1 parent 21b319f commit bdfae36

7 files changed

Lines changed: 30 additions & 5 deletions

File tree

conf/smart-default.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@
4949
</description>
5050
</property>
5151

52+
<property>
53+
<name>smart.work.dir</name>
54+
<value>/system/ssm</value>
55+
<description>
56+
This directory is used as a work directory for SSM to store tmp files and data.
57+
The default path is "/system/ssm", and SSM will ignore files under the work directory.
58+
No more than one directory can be set as the work directory.
59+
</description>
60+
</property>
61+
5262
<property>
5363
<name>smart.server.rpc.address</name>
5464
<value>0.0.0.0:7042</value>

smart-client/src/main/java/org/smartdata/client/SmartClient.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ private void initialize(InetSocketAddress address) throws IOException {
8181
singleIgnoreList = new ConcurrentHashMap<>(200);
8282
ignoreAccessEventDirs = ((SmartConf) conf).getIgnoreDir();
8383
fetchAccessEventDirs = ((SmartConf) conf).getCoverDir();
84-
8584
}
8685

8786
private void checkOpen() throws IOException {

smart-common/src/main/java/org/smartdata/conf/SmartConf.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import java.util.Scanner;
3535
import java.util.Set;
3636

37-
3837
/**
3938
* SSM related configurations as well as HDFS configurations.
4039
*/
@@ -53,8 +52,13 @@ public SmartConf() {
5352
SmartConfKeys.SMART_IGNORE_DIRS_KEY);
5453
Collection<String> fetchDirs = this.getTrimmedStringCollection(
5554
SmartConfKeys.SMART_COVER_DIRS_KEY);
55+
5656
ignoreList = new ArrayList<>();
5757
coverList = new ArrayList<>();
58+
String tmpDir = this.get(
59+
SmartConfKeys.SMART_WORK_DIR_KEY, SmartConfKeys.SMART_WORK_DIR_DEFAULT);
60+
tmpDir = tmpDir + (tmpDir.endsWith("/") ? "" : "/");
61+
ignoreList.add(tmpDir);
5862
for (String s : ignoreDirs) {
5963
ignoreList.add(s + (s.endsWith("/") ? "" : "/"));
6064
}
@@ -86,7 +90,7 @@ public void setIgnoreDir(ArrayList<String> ignoreDirs) {
8690
for (String s : ignoreDirs) {
8791
ignoreList.add(s + (s.endsWith("/") ? "" : "/"));
8892
}
89-
}
93+
}
9094

9195
public Set<String> init(String fileName, SmartConf conf) {
9296
String hostName = "";

smart-common/src/main/java/org/smartdata/conf/SmartConfKeys.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ public class SmartConfKeys {
181181
* For more than one directories, they should be separated by ",".
182182
*/
183183
public static final String SMART_COVER_DIRS_KEY = "smart.cover.dirs";
184+
public static final String SMART_WORK_DIR_KEY = "smart.work.dir";
185+
public static final String SMART_WORK_DIR_DEFAULT = "/system/ssm/";
184186

185187
// Target cluster
186188
public static final String SMART_STORAGE_INFO_UPDATE_INTERVAL_KEY =

smart-hadoop-support/smart-hadoop/src/main/java/org/smartdata/hdfs/metric/fetcher/NamespaceFetcher.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,11 @@ public void run() {
295295
throw new IOException();
296296
}
297297

298+
if(!status.isDir()) {
299+
this.addFileStatus(convertToFileInfo(status, parent));
300+
numFilesFetched.incrementAndGet();
301+
}
302+
298303
if (status.isDir()) {
299304
if (startAfter == null) {
300305
FileInfo internal = convertToFileInfo(status, "");

smart-hadoop-support/smart-hadoop/src/main/java/org/smartdata/hdfs/scheduler/ErasureCodingScheduler.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ public class ErasureCodingScheduler extends ActionSchedulerService {
4848
public static final String listecActionID = "listec";
4949
public static final List<String> actions =
5050
Arrays.asList(ecActionID, unecActionID, checkecActionID, listecActionID);
51-
public static final String EC_DIR = "/system/ssm/ec_tmp/";
51+
public static String EC_DIR;
52+
public static final String EC_TMP_DIR = "ec_tmp/";
5253
public static final String EC_TMP = "-ecTmp";
5354
public static final String EC_POLICY = "-policy";
5455
private Set<String> fileLock;
@@ -66,6 +67,10 @@ public ErasureCodingScheduler(SmartContext context, MetaStore metaStore) {
6667
if (this.throttleInMb > 0) {
6768
this.rateLimiter = RateLimiter.create(throttleInMb);
6869
}
70+
String ssmTmpDir = conf.get(
71+
SmartConfKeys.SMART_WORK_DIR_KEY, SmartConfKeys.SMART_WORK_DIR_DEFAULT);
72+
ssmTmpDir = ssmTmpDir + (ssmTmpDir.endsWith("/") ? "" : "/");
73+
ErasureCodingScheduler.EC_DIR = ssmTmpDir + EC_TMP_DIR;
6974
}
7075

7176
public List<String> getSupportedActions() {

smart-server/src/test/java/org/smartdata/server/engine/cmdlet/TestCompressionReadWrite.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public void testCompressEmptyFile() throws Exception {
124124
+ " -bufSize " + bufSize + " -compressImpl " + compressionImpl);
125125

126126
waitTillActionDone(cmdId);
127-
Thread.sleep(600);
127+
Thread.sleep(5000);
128128
// metastore test
129129
FileState fileState = metaStore.getFileState(fileName);
130130
Assert.assertEquals(FileState.FileType.COMPRESSION, fileState.getFileType());

0 commit comments

Comments
 (0)