Commit c2aac233 authored by ymwangya's avatar ymwangya

new

parent 47651670
......@@ -50,23 +50,6 @@ public class FileService{
private String[] ipList = new String[29];
private List <Integer> index = new ArrayList<Integer>() {} ;
long startTime = System.currentTimeMillis(); // 获取开始时间
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
/*获取容器ip*/
public String[] getIpList(Long clusterId, String appName) {
List<String> ipListS = networkService.getIpListByAppName(clusterId, appName);//用于存储容器ip的list集合
String[] containerIp = new String[ipListS.size()];//将集合中的元素存在数组里,因为下边用的是数组
for (int i = 0; i < ipListS.size(); i++) {
if(!ipListS.isEmpty()){
String ip_tmp = ipListS.get(i);
String rep = ip_tmp.replaceAll("[\\[\\]]","");
String[] split_list = rep.split("/");
containerIp[i] = split_list[0]+":8082";
}
}
return containerIp;
}
public String getIpByAppName(Long clusterId,String appName) {
List<String> ipList = networkService.getIpListByAppName(clusterId, appName);
......@@ -84,12 +67,16 @@ public class FileService{
* @param bufferedImage
* @return
*/
long startTime = System.currentTimeMillis()/1000; // 获取开始时间
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
@Async("taskExecutor")
public String sendFile(Long fileId, BufferedImage bufferedImage) {
//long startTime = System.currentTimeMillis(); // 获取开始时间
System.out.println("The current system time at the beginning of the program:" +df.format(new Date()));// new Date()为获取当前系统时间
System.out.println("The execution time at the beginning of the program:"+startTime);
// System.out.println("-----------------------------The time of sending file--------------------------------");
// long startTime = System.currentTimeMillis()/1000; // 获取开始时间
System.out.println("The current system time at the beginning of the program:" +df.format(new Date()));// new Date()为获取当前系统时间
for (int i = 0; i < wxName_list.length; i++){
ipList[i] = getIpByAppName(clusterId,wxName_list[i]);//通过卫星名字获取卫星ip
......@@ -118,7 +105,14 @@ public class FileService{
}
}
}
/* long endTime = System.currentTimeMillis()/1000; //获取程序结束时间
System.out.println("The current system time at the end of the program:"+ df.format(new Date()));// new Date()为获取当前系统时间
System.out.println("The total running time of the program:" + (endTime - startTime) + "s");
System.out.println("=====================================================================================");*/
return "success";
}
// 发送文件切片到目标地址
......@@ -139,6 +133,11 @@ public class FileService{
}
public String getFile(String fileName, Long fileId) {
/* System.out.println("--------------------The time of geting file------------------------------------------");
long startTime1 = System.currentTimeMillis()/1000; // 获取开始时间
System.out.println("The current system time at the beginning of the program:" +df.format(new Date()));*/
for (int i = 0; i < wxName_list.length; i++){
ipList[i] = getIpByAppName(clusterId,wxName_list[i]);//通过卫星名字获取卫星ip
}
......@@ -147,10 +146,10 @@ public class FileService{
//异常处理
for (int k = 0; k < 5; k++) {
try {
//Set<FileSlice> fileSliceSet = getFileSlice(ipList[index.get(k)], fileId);
//System.out.println("recive "+wxName_list[index.get(k)]+" success");
Set<FileSlice> fileSliceSet = getFileSlice(ipList[k], fileId);
System.out.println("recive "+wxName_list[k]+" success");
Set<FileSlice> fileSliceSet = getFileSlice(ipList[index.get(k)], fileId);
System.out.println("recive "+wxName_list[index.get(k)]+" success");
// Set<FileSlice> fileSliceSet = getFileSlice(ipList[k], fileId);
// System.out.println("recive "+wxName_list[k]+" success");
result.addAll(fileSliceSet);
}catch (Exception e){
System.out.println("recive fileslice fail");
......@@ -159,12 +158,16 @@ public class FileService{
List<FileSlice> list = new ArrayList<>(result);
SplitResult splitResult = new SplitResult();
splitResult.setFileSliceList(sortList(list));
//merge
ComputingResult computingResult = hadoopComService.sliceComputing(splitResult);
MergeResult mergeResult = hadoopComService.sliceMerge(computingResult,sliceNum);
//save
try {
saveFile(fileName, mergeResult);
long endTime = System.currentTimeMillis()/1000; //获取程序结束时间
System.out.println("The current system time at the end of the program:"+ df.format(new Date()));// new Date()为获取当前系统时间
System.out.println("The total running time of the program:" + (endTime - startTime) + "s");
return "success";
} catch (Exception e) {
e.printStackTrace();
......@@ -197,10 +200,10 @@ public class FileService{
} catch (IOException e) {
e.printStackTrace();
}
long endTime = System.currentTimeMillis(); //获取程序结束时间
/* long endTime = System.currentTimeMillis(); //获取程序结束时间
System.out.println("The current system time at the end of the program:"+ df.format(new Date()));// new Date()为获取当前系统时间
System.out.println("The execution time at the end of the program:"+ endTime);
System.out.println("The total running time of the program:" + (endTime - startTime) + "ms");
System.out.println("The total running time of the program:" + (endTime - startTime) + "ms");*/
}
public List <Integer> getIndex(int num){
......
......@@ -85,7 +85,7 @@ public class HadoopTest {
DockerContainer container0 = new DockerContainer();
container0.setName(wxData.get(wxData.size()-1).getName());
container0.setCommand("sh");
container0.setImage("hadoop_client");
container0.setImage("hadoop");
container0.setPorts("8999");//指定容器端口
containerDescription0.setDockerContainer(container0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment