Commit ad5cb34d authored by ymwang's avatar ymwang

中间结果存储

parent e16ebe33
......@@ -41,23 +41,22 @@ public class FileService{
@Autowired
private DistributedComService distributedComService;
private String[] ipList=null;
Long clusterId = 11113L;//docker集群ID
String[] wxName_list = new String[]{"sate2","sate3","sate4","sate5","sate6","sate7","sate8","sate9","sate10","sate11",
String[] wxName_list = new String[]{"sate1","sate2","sate3","sate4","sate5","sate6","sate7","sate8","sate9","sate10","sate11",
"sate12","sate13","sate14","sate15","sate16","sate17","sate18","sate19","sate20","sate21",
"sate22","sate23","sate24","sate25","sate26","sate27","sate28","sate29","sate30"};//获取卫星名字
"sate22","sate23","sate24","sate25","sate26","sate27","sate28","sate29"};//获取卫星名字
@PostConstruct
private String[] ipList = new String[29];
/* @PostConstruct
public void init() {
/* ipList = getIpList(11113l,"dbc_server");
System.out.println(Arrays.toString(ipList));*/
*//* ipList = getIpList(11113l,"dbc_server");
System.out.println(Arrays.toString(ipList));*//*
for (int k = 0; k < wxName_list.length; k++){
ipList = getIpList(clusterId,wxName_list[k]);//通过卫星名字获取卫星ip
ipList[k] = getIpList(clusterId,wxName_list[k]);//通过卫星名字获取卫星ip
}
}
*/
/*获取容器ip*/
/* String[] ipList = new String[]{"127.0.0.1:8080","127.0.0.1:8081","127.0.0.1:8082","127.0.0.1:8083","127.0.0.1:8084",
"127.0.0.1:8085","127.0.0.1:8086"};*/
......@@ -75,6 +74,15 @@ public class FileService{
return containerIp;
}
public String getIpByAppName(Long clusterId,String appName) {
List<String> ipList = networkService.getIpListByAppName(clusterId, appName);
if(!ipList.isEmpty()){
String ip_tmp = ipList.get(0);
String[] split_list = ip_tmp.split("/");
return split_list[0] + ":8082";
}
return null;
}
/**
* 发送文件到分布式节点
......@@ -89,7 +97,7 @@ public class FileService{
//ipList = getIpList(11113l,"dbc_server");
for (int i = 0; i < wxName_list.length; i++){
ipList = getIpList(clusterId,wxName_list[i]);//通过卫星名字获取卫星ip
ipList[i] = getIpByAppName(clusterId,wxName_list[i]);//通过卫星名字获取卫星ip
}
//查看ip
System.out.println(ipList.length);
......@@ -107,7 +115,7 @@ public class FileService{
try {
sendFileSlice(ipList[ipIndex], slice);
//
System.out.println("send "+ipList[ipIndex]+"sucess");
System.out.println("send "+ipList[ipIndex]+"success");
ipIndex = (ipIndex + 1) % ipList.length;
break;
}catch (Exception e){
......@@ -150,7 +158,7 @@ public class FileService{
public String getFile(String fileName, Long fileId) {
//ipList = getIpList(11113l,"dbc_server");
for (int i = 0; i < wxName_list.length; i++){
ipList = getIpList(clusterId,wxName_list[i]);//通过卫星名字获取卫星ip
ipList[i] = getIpByAppName(clusterId,wxName_list[i]);//通过卫星名字获取卫星ip
}
int sliceNum = ipList.length;
//int sliceNum = ipList.length;
......
......@@ -14,8 +14,8 @@ import java.io.IOException;
@Service
public class FileServiceImpl implements FileService {
@Value("${dbc.directory.output}")
private String directoryOutput;
/*@Value("${dbc.directory.output}")
private String directoryOutput;*/
//分散计算
@Override
......@@ -59,7 +59,7 @@ public class FileServiceImpl implements FileService {
}
}
//这里需提供新的文件输出
ImageIO.write(grayImage, "jpg", new File(directoryOutput+"out"));
ImageIO.write(grayImage, "jpg", new File("/tmp/static/out.jpg"));
System.out.println("download sucess");
return true;
}
......
......@@ -54,7 +54,7 @@ public class TopoTests {
//创建容器
ContainerDescription containerDescription0 = new ContainerDescription();
/* ContainerDescription containerDescription0 = new ContainerDescription();
containerDescription0.setMode("normal");
containerDescription0.setReplicas(1);
......@@ -65,8 +65,8 @@ public class TopoTests {
container0.setPorts("8999");//指定容器端口
containerDescription0.setDockerContainer(container0);
cds.add(containerDescription0);
for (int k = 1; k < wxData.size(); k++) {
cds.add(containerDescription0);*/
for (int k = 0; k < wxData.size()-1; k++) {
ContainerDescription containerDescription = new ContainerDescription();
containerDescription.setMode("normal");
containerDescription.setReplicas(1);
......@@ -79,7 +79,19 @@ public class TopoTests {
containerDescription.setDockerContainer(container);
cds.add(containerDescription);
}
ContainerDescription containerDescription0 = new ContainerDescription();
containerDescription0.setMode("normal");
containerDescription0.setReplicas(1);
DockerContainer container0 = new DockerContainer();
container0.setName(wxData.get(wxData.size()-1).getName());
container0.setCommand("sh");
container0.setImage("dbc_client");
container0.setPorts("8999");//指定容器端口
containerDescription0.setDockerContainer(container0);
cds.add(containerDescription0);
/////////////////////////////////////////////
clusterConfig.setDockers(cds);
NetworkTopology topo = new NetworkTopology();
topo.setAppNames(tp.getAppNames(wxData));
......
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