Commit b1f9cdb1 authored by Elf's avatar Elf

放在kvm中

问题
可能会出现sateIP.txt这个文件找不到的情况
parent f6bd61a8
......@@ -37,12 +37,6 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>top.ninwoo</groupId>
<artifactId>cnf-client-starter</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-thymeleaf -->
<dependency>
<groupId>org.springframework.boot</groupId>
......
package top.ninwoo.dbc.client.service;
import top.ninwoo.bishe.starter.service.NetworkService;
import top.ninwoo.dbc.api.po.*;
import top.ninwoo.dbc.api.service.DistributedComService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
......@@ -11,11 +8,17 @@ import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import top.ninwoo.dbc.api.po.ComputingResult;
import top.ninwoo.dbc.api.po.FileSlice;
import top.ninwoo.dbc.api.po.MergeResult;
import top.ninwoo.dbc.api.po.SplitResult;
import top.ninwoo.dbc.api.service.DistributedComService;
import javax.annotation.PostConstruct;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.*;
......@@ -35,17 +38,15 @@ public class FileService{
@Autowired
private RestTemplate restTemplate;
@Autowired
private NetworkService networkService;
@Autowired
private DistributedComService distributedComService;
//不需要了,我懒得改
Long clusterId = 11113L;//docker集群ID
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"};//获取卫星名字
String[] wxName_list = new String[]{"sate1","sate2","sate3","sate4"};//获取卫星名字
private String[] ipList = new String[29];
......@@ -62,7 +63,7 @@ public class FileService{
/*获取容器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"};*/
public String[] getIpList(Long clusterId, String appName) {
/* 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++) {
......@@ -74,9 +75,9 @@ public class FileService{
}
}
return containerIp;
}
}*/
public String getIpByAppName(Long clusterId,String appName) {
/* public String getIpByAppName(Long clusterId,String appName) {
List<String> ipList = networkService.getIpListByAppName(clusterId, appName);
if(!ipList.isEmpty()){
String ip_tmp = ipList.get(0);
......@@ -84,6 +85,24 @@ public class FileService{
return split_list[0] + ":8082";
}
return null;
}*/
//todo 可能会有找不到文件的情况
public String getIpByAppName(Long clusterId,String appName) {
String str;
File file = new File(directoryOutput+"sateIP.txt");
try{
BufferedReader br = new BufferedReader(new FileReader(file));
while((str = br.readLine()) != null){
if (str.startsWith(appName)){
String sateIp = str.split(":")[1];
return sateIp + ":8082";
}
}
}catch(Exception e){
e.printStackTrace();
}
return null;
}
/**
......
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