Commit ad5cb34d authored by ymwang's avatar ymwang

中间结果存储

parent e16ebe33
...@@ -41,23 +41,22 @@ public class FileService{ ...@@ -41,23 +41,22 @@ public class FileService{
@Autowired @Autowired
private DistributedComService distributedComService; private DistributedComService distributedComService;
private String[] ipList=null;
Long clusterId = 11113L;//docker集群ID 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", "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() { public void init() {
/* ipList = getIpList(11113l,"dbc_server"); *//* ipList = getIpList(11113l,"dbc_server");
System.out.println(Arrays.toString(ipList));*/ System.out.println(Arrays.toString(ipList));*//*
for (int k = 0; k < wxName_list.length; k++){ 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*/ /*获取容器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", /* 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"};*/ "127.0.0.1:8085","127.0.0.1:8086"};*/
...@@ -75,6 +74,15 @@ public class FileService{ ...@@ -75,6 +74,15 @@ public class FileService{
return containerIp; 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{ ...@@ -89,7 +97,7 @@ public class FileService{
//ipList = getIpList(11113l,"dbc_server"); //ipList = getIpList(11113l,"dbc_server");
for (int i = 0; i < wxName_list.length; i++){ 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 //查看ip
System.out.println(ipList.length); System.out.println(ipList.length);
...@@ -107,7 +115,7 @@ public class FileService{ ...@@ -107,7 +115,7 @@ public class FileService{
try { try {
sendFileSlice(ipList[ipIndex], slice); sendFileSlice(ipList[ipIndex], slice);
// //
System.out.println("send "+ipList[ipIndex]+"sucess"); System.out.println("send "+ipList[ipIndex]+"success");
ipIndex = (ipIndex + 1) % ipList.length; ipIndex = (ipIndex + 1) % ipList.length;
break; break;
}catch (Exception e){ }catch (Exception e){
...@@ -150,7 +158,7 @@ public class FileService{ ...@@ -150,7 +158,7 @@ public class FileService{
public String getFile(String fileName, Long fileId) { public String getFile(String fileName, Long fileId) {
//ipList = getIpList(11113l,"dbc_server"); //ipList = getIpList(11113l,"dbc_server");
for (int i = 0; i < wxName_list.length; i++){ 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;
//int sliceNum = ipList.length; //int sliceNum = ipList.length;
......
...@@ -14,8 +14,8 @@ import java.io.IOException; ...@@ -14,8 +14,8 @@ import java.io.IOException;
@Service @Service
public class FileServiceImpl implements FileService { public class FileServiceImpl implements FileService {
@Value("${dbc.directory.output}") /*@Value("${dbc.directory.output}")
private String directoryOutput; private String directoryOutput;*/
//分散计算 //分散计算
@Override @Override
...@@ -59,7 +59,7 @@ public class FileServiceImpl implements FileService { ...@@ -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"); System.out.println("download sucess");
return true; return true;
} }
......
...@@ -54,7 +54,7 @@ public class TopoTests { ...@@ -54,7 +54,7 @@ public class TopoTests {
//创建容器 //创建容器
ContainerDescription containerDescription0 = new ContainerDescription(); /* ContainerDescription containerDescription0 = new ContainerDescription();
containerDescription0.setMode("normal"); containerDescription0.setMode("normal");
containerDescription0.setReplicas(1); containerDescription0.setReplicas(1);
...@@ -65,8 +65,8 @@ public class TopoTests { ...@@ -65,8 +65,8 @@ public class TopoTests {
container0.setPorts("8999");//指定容器端口 container0.setPorts("8999");//指定容器端口
containerDescription0.setDockerContainer(container0); containerDescription0.setDockerContainer(container0);
cds.add(containerDescription0); cds.add(containerDescription0);*/
for (int k = 1; k < wxData.size(); k++) { for (int k = 0; k < wxData.size()-1; k++) {
ContainerDescription containerDescription = new ContainerDescription(); ContainerDescription containerDescription = new ContainerDescription();
containerDescription.setMode("normal"); containerDescription.setMode("normal");
containerDescription.setReplicas(1); containerDescription.setReplicas(1);
...@@ -79,7 +79,19 @@ public class TopoTests { ...@@ -79,7 +79,19 @@ public class TopoTests {
containerDescription.setDockerContainer(container); containerDescription.setDockerContainer(container);
cds.add(containerDescription); 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); clusterConfig.setDockers(cds);
NetworkTopology topo = new NetworkTopology(); NetworkTopology topo = new NetworkTopology();
topo.setAppNames(tp.getAppNames(wxData)); 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