jiapeng 6 年 前
コミット
0c7ea219b5

+ 2 - 0
src/main/java/com/ekexiu/project/hdfs/HdfsService.java

@ -6,6 +6,8 @@ import org.apache.hadoop.conf.Configuration;
6 6
import org.apache.hadoop.fs.FileSystem;
7 7
import org.apache.hadoop.fs.Path;
8 8
import org.apache.hadoop.hdfs.DistributedFileSystem;
9
import org.jfw.apt.annotation.Bean;
10
@Bean
9 11
public class HdfsService {
10 12
	private Configuration configuration = new Configuration();
11 13
	private DistributedFileSystem dfs;

+ 3 - 0
src/main/java/com/ekexiu/project/storage/diacrisis/AiCleanTask.java

@ -51,6 +51,9 @@ public class AiCleanTask implements Runnable{
51 51
							ret = ret.trim();
52 52
							if (ret.equals("1")) {
53 53
								aiTaskService.updateTaskState(taskId, 399, null, new AiStrengthenTask(taskId, taskType, aiTaskService));
54
								file = new File(aiTaskService.getDstPath(), taskId);
55
								file = new File(file,"data_desen");
56
								aiTaskService.uploadToHdfs(taskId,file);
54 57
								return;
55 58
							}
56 59
						}

+ 24 - 0
src/main/java/com/ekexiu/project/storage/diacrisis/AiTaskService.java

@ -25,6 +25,7 @@ import org.jfw.util.jdbc.JdbcUtil;
25 25
import org.jfw.util.log.LogFactory;
26 26
import org.jfw.util.log.Logger;
27 27

28
import com.ekexiu.project.hdfs.HdfsService;
28 29
import com.ekexiu.project.storage.system.SessionUser;
29 30

30 31
@Path("/task")
@ -33,12 +34,24 @@ public class AiTaskService {
33 34
	private static Logger LOG = LogFactory.getLog(AiTaskService.class);
34 35

35 36
	private long delayTime = 2000;
37
	
38
	@Autowrie
39
	private HdfsService hdfsService;
36 40

37 41
	@Autowrie
38 42
	private AiTaskDao aiTaskDao;
39 43
	private File srcPath = new File("/ekexiu/storage_asd/src");
40 44
	private File dstPath = new File("/ekexiu/storage_asd/dst");
41 45

46
	
47
	public HdfsService getHdfsService() {
48
		return hdfsService;
49
	}
50

51
	public void setHdfsService(HdfsService hdfsService) {
52
		this.hdfsService = hdfsService;
53
	}
54

42 55
	public File getSrcPath() {
43 56
		return srcPath;
44 57
	}
@ -63,6 +76,17 @@ public class AiTaskService {
63 76
		this.aiTaskDao = aiTaskDao;
64 77
	}
65 78

79
	public void uploadToHdfs(final String dst,final File src){
80
		JfwAppContext.getScheduledExecutorService().submit(new Runnable() {
81
			@Override
82
			public void run() {
83
			    try{
84
			    	hdfsService.upload(dst, src);
85
			    }catch(Throwable tr){
86
			    }
87
			}
88
		});
89
	}
66 90
	public boolean copyFile(File src, File dst) {
67 91
		try {
68 92
			if (src.exists() && (!dst.exists())) {

+ 4 - 18
src/main/java/com/ekexiu/project/storage/diacrisis/AiTransferTask.java

@ -27,30 +27,16 @@ public class AiTransferTask implements Runnable {
27 27
		} else {
28 28
				file = new File(file,"data");
29 29
				if (file.mkdirs()) {
30
					if (taskType == 1) {
31
						for (int i = 1; i < 7; ++i) {
32
							File src = new File(aiTaskService.getSrcPath(), "IM_" + String.format("%04d.DICOM", i));
33
							File dst = new File(file, "IM_" + String.format("%04d.DICOM", i));
30
					for(String fn:aiTaskService.getSrcPath().list()){
31
						if(fn.length()>6 &&  fn.substring(fn.length()-6).equalsIgnoreCase(".DICOM")){
32
							File src = new File(aiTaskService.getSrcPath(), fn);
33
							File dst = new File(file, fn);
34 34
							if (!aiTaskService.copyFile(src, dst)) {
35 35
								LOG.error("copy File[" + src.getAbsolutePath() + "] error");
36 36
								aiTaskService.updateTaskState(taskId, 250, "ERR0199", null);
37 37
								return;
38 38
							}
39 39
						}
40
					} else if (taskType == 2) {
41
						for (int i = 7; i < 14; ++i) {
42
							File src = new File(aiTaskService.getSrcPath(), "IM_" + String.format("%04d.DICOM", i));
43
							File dst = new File(file, "IM_" + String.format("%04d.DICOM", i));
44
							if (!aiTaskService.copyFile(src, dst)) {
45
								LOG.error("copy File[" + src.getAbsolutePath() + "] error");
46
								aiTaskService.updateTaskState(taskId, 250, "ERR0199", null);
47
								return;
48
							}
49
						}
50
					} else {
51
						LOG.error("err task type[" + taskType + "]");
52
						aiTaskService.updateTaskState(taskId, 250, "ERR0199", null);
53
						return;
54 40
					}
55 41
					aiTaskService.updateTaskState(taskId, 299, null, new AiCleanTask(taskId, taskType, aiTaskService));
56 42
				} else {

+ 2 - 1
src/main/resources/project.properties

@ -32,4 +32,5 @@ dataSource.maxPoolPreparedStatementPerConnectionSize::int=20
32 32
#Ĭ�ϵ�SQL����Զ��ύ״̬(������ر�)���������ӳر�������(false�����ӳض�)
33 33
dataSource.defaultAutoCommit::boolean=false
34 34
35
com_ekexiu_project_storage_resource_service_StorageService.filePath::java.io.File=/ekexiu/storage/data
35
com_ekexiu_project_storage_resource_service_StorageService.filePath::java.io.File=/ekexiu/storage/data
36
com_ekexiu_project_hdfs_HdfsService.remoteUrl=hdfs://39.97.161.48:9000