-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathCosNCopyFileTask.java
47 lines (40 loc) · 1.5 KB
/
CosNCopyFileTask.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package org.apache.hadoop.fs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
public class CosNCopyFileTask implements Runnable {
private static final Logger LOG = LoggerFactory.getLogger(CosNCopyFileTask.class);
private final NativeFileSystemStore store;
private final String srcKey;
private final FileMetadata srcFileMetadata;
private final String dstKey;
private final CosNCopyFileContext cosCopyFileContext;
public CosNCopyFileTask(NativeFileSystemStore store,
String srcKey, FileMetadata srcFileMetadata,
String dstKey,
CosNCopyFileContext cosCopyFileContext) {
this.store = store;
this.srcKey = srcKey;
this.srcFileMetadata = srcFileMetadata;
this.dstKey = dstKey;
this.cosCopyFileContext = cosCopyFileContext;
}
@Override
public void run() {
boolean fail = false;
try {
this.store.copy(srcKey, this.srcFileMetadata, dstKey);
} catch (IOException e) {
LOG.warn("Exception thrown when copy from {} to {}", this.srcKey, this.dstKey, e);
fail = true;
} finally {
this.cosCopyFileContext.lock();
if (fail) {
cosCopyFileContext.setCopySuccess(false);
}
cosCopyFileContext.incCopiesFinish();
cosCopyFileContext.signalAll();
cosCopyFileContext.unlock();
}
}
}