|
@@ -1,6 +1,5 @@
|
|
package com.caesolver.server;
|
|
package com.caesolver.server;
|
|
|
|
|
|
-
|
|
|
|
import java.io.BufferedReader;
|
|
import java.io.BufferedReader;
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.io.FileWriter;
|
|
import java.io.FileWriter;
|
|
@@ -23,11 +22,12 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
import com.caesolver.server.util.HttpDownload;
|
|
import com.caesolver.server.util.HttpDownload;
|
|
import com.caesolver.server.util.HttpUtils;
|
|
import com.caesolver.server.util.HttpUtils;
|
|
|
|
+import com.caesolver.server.util.TimeUtils;
|
|
import com.caesolver.sftp.FileUtil;
|
|
import com.caesolver.sftp.FileUtil;
|
|
import com.caesolver.sftp.SFTPUtil;
|
|
import com.caesolver.sftp.SFTPUtil;
|
|
|
|
|
|
import net.sf.json.JSONObject;
|
|
import net.sf.json.JSONObject;
|
|
-
|
|
|
|
|
|
+
|
|
@Component
|
|
@Component
|
|
public class SolverService {
|
|
public class SolverService {
|
|
@Value("${caeserverurl}")
|
|
@Value("${caeserverurl}")
|
|
@@ -36,234 +36,266 @@ public class SolverService {
|
|
String esurl;
|
|
String esurl;
|
|
@Value("${solverBatchStopUrl}")
|
|
@Value("${solverBatchStopUrl}")
|
|
String solverBatchStopUrl;
|
|
String solverBatchStopUrl;
|
|
-
|
|
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
SolverHcfdOrderUtil hcfdOrderUtil;
|
|
SolverHcfdOrderUtil hcfdOrderUtil;
|
|
@Autowired
|
|
@Autowired
|
|
SFTPUtil sftpUtil;
|
|
SFTPUtil sftpUtil;
|
|
@Value("${HCFD.workdir}")
|
|
@Value("${HCFD.workdir}")
|
|
- String hcfdWorkDir ;
|
|
|
|
-
|
|
|
|
- public static boolean ISRUN =false;
|
|
|
|
- protected static Logger log=LoggerFactory.getLogger(SolverService.class);
|
|
|
|
-
|
|
|
|
- public boolean isRun() {
|
|
|
|
- return ISRUN;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public void precessController(SolverBatchHcfd vo)
|
|
|
|
- throws IOException, Exception {
|
|
|
|
-
|
|
|
|
- //logPut(vo,"Solver start");
|
|
|
|
- filehHcfdDown(vo);//下载文件
|
|
|
|
- String jobOrder =hcfdOrderUtil.createOrder(vo);
|
|
|
|
- jobExec( jobOrder, vo);
|
|
|
|
|
|
+ String hcfdWorkDir;
|
|
|
|
+
|
|
|
|
+ public static boolean ISRUN = false;
|
|
|
|
+ protected static Logger log = LoggerFactory.getLogger(SolverService.class);
|
|
|
|
+
|
|
|
|
+ public boolean isRun() {
|
|
|
|
+ return ISRUN;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void precessController(SolverBatchHcfd vo) throws IOException, Exception {
|
|
|
|
+ String startTime =TimeUtils.getNow();
|
|
|
|
+ logPut(vo, "Solver start");
|
|
|
|
+ filehHcfdDown(vo);// 下载文件
|
|
|
|
+ String jobOrder = hcfdOrderUtil.createOrder(vo);
|
|
|
|
+ jobExec(jobOrder, vo);
|
|
sftpUtil.uploadBatchDataOut(vo);
|
|
sftpUtil.uploadBatchDataOut(vo);
|
|
// //求解结束
|
|
// //求解结束
|
|
- logPut(vo,"Solver end");
|
|
|
|
|
|
+ logPut(vo, "Solver end");
|
|
|
|
+ String endTime =TimeUtils.getNow();
|
|
|
|
+ this.consume(vo.getNmlId(), startTime, endTime,"hcfdbatch");
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- private void jobExec( String jobOrder, SolverBatchHcfd vo) throws Exception {
|
|
|
|
- Process p =null;
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 资源消费接口
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+ @Async
|
|
|
|
+ private void consume(String pid,String startTime,String endTime,String type) throws Exception {
|
|
|
|
+ Map<String, String> paramMap = new HashMap<>();
|
|
|
|
+ paramMap.put("channelNo", "service");
|
|
|
|
+ paramMap.put("clientToken", "e47b87eec69545559d1e81e56626da68");
|
|
|
|
+ paramMap.put("transCode", "HG00003");
|
|
|
|
+ paramMap.put("otherId", pid);
|
|
|
|
+ paramMap.put("startTime", startTime);
|
|
|
|
+ paramMap.put("endTime", endTime);
|
|
|
|
+ paramMap.put("type", type);
|
|
|
|
+ paramMap.put("userId", "5f06c8bc77234f969d13e160b54c27e3");
|
|
|
|
+ HttpUtils.doPost(url, "", "",
|
|
|
|
+ new HashMap<String, String>(),
|
|
|
|
+ new HashMap<String, String>(), paramMap);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void jobExec(String jobOrder, SolverBatchHcfd vo) throws Exception {
|
|
|
|
+ Process p = null;
|
|
Runtime runtime = Runtime.getRuntime();
|
|
Runtime runtime = Runtime.getRuntime();
|
|
- p= runtime.exec(jobOrder);
|
|
|
|
- jobStateLine(vo.getNmlId(), solverBatchStopUrl);//修改状态 为求解中
|
|
|
|
|
|
+ p = runtime.exec(jobOrder);
|
|
|
|
+ jobStateLine(vo.getNmlId(), solverBatchStopUrl);// 修改状态 为求解中
|
|
InputStream fis = p.getInputStream();
|
|
InputStream fis = p.getInputStream();
|
|
InputStreamReader isr = new InputStreamReader(fis);
|
|
InputStreamReader isr = new InputStreamReader(fis);
|
|
BufferedReader br = new BufferedReader(isr);
|
|
BufferedReader br = new BufferedReader(isr);
|
|
String line = null;
|
|
String line = null;
|
|
- boolean isSuccess=true;
|
|
|
|
|
|
+ boolean isSuccess = true;
|
|
while ((line = br.readLine()) != null) {
|
|
while ((line = br.readLine()) != null) {
|
|
log.info(line);
|
|
log.info(line);
|
|
- if(!line.trim().equals("")) {
|
|
|
|
- logPut(vo,line);
|
|
|
|
- }
|
|
|
|
- if(isSuccess&&line.contains("Error")) {//包含Error
|
|
|
|
- isSuccess=false;
|
|
|
|
- }
|
|
|
|
|
|
+ if (!line.trim().equals("")) {
|
|
|
|
+ logPut(vo, line);
|
|
|
|
+ }
|
|
|
|
+ if (isSuccess && line.contains("Error")) {// 包含Error
|
|
|
|
+ isSuccess = false;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
p.waitFor();
|
|
p.waitFor();
|
|
- if(isSuccess) {//成功
|
|
|
|
- jobStateSuccess(vo.getNmlId());//修改状态 为求解成功
|
|
|
|
- }else {//失败
|
|
|
|
- jobStateError(vo.getNmlId());;//修改状态 为求解失败
|
|
|
|
|
|
+ if (isSuccess) {// 成功
|
|
|
|
+ jobStateSuccess(vo.getNmlId());// 修改状态 为求解成功
|
|
|
|
+ } else {// 失败
|
|
|
|
+ jobStateError(vo.getNmlId());
|
|
|
|
+ ;// 修改状态 为求解失败
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
- //日志文件输入
|
|
|
|
- private void logPut(SolverBatchHcfd vo,String line) throws Exception {
|
|
|
|
- String gridFristName =vo.getGridName().split("\\.")[0];
|
|
|
|
- File workerDataDataout =new File(hcfdWorkDir+"/"+vo.getNmlId()+"/"+gridFristName+"/test/"+"data_out");
|
|
|
|
- File f = new File(workerDataDataout+"/run.log");
|
|
|
|
- if(!f.exists()) {
|
|
|
|
|
|
+ // 日志文件输入
|
|
|
|
+ private void logPut(SolverBatchHcfd vo, String line) throws Exception {
|
|
|
|
+ String gridFristName = vo.getGridName().split("\\.")[0];
|
|
|
|
+ File workerDataDataout = new File(
|
|
|
|
+ hcfdWorkDir + "/" + vo.getNmlId() + "/" + gridFristName + "/test/" + "data_out");
|
|
|
|
+ File f = new File(workerDataDataout + "/run.log");
|
|
|
|
+ if (!f.exists()) {
|
|
f.createNewFile();
|
|
f.createNewFile();
|
|
}
|
|
}
|
|
- FileWriter writer = new FileWriter(f,true);
|
|
|
|
|
|
+ FileWriter writer = new FileWriter(f, true);
|
|
writer.append(line);
|
|
writer.append(line);
|
|
- writer.write("\n");//换行
|
|
|
|
|
|
+ writer.write("\n");// 换行
|
|
writer.flush();
|
|
writer.flush();
|
|
- writer.close();
|
|
|
|
|
|
+ writer.close();
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
- * 文件下载
|
|
|
|
- *
|
|
|
|
|
|
+ * 文件下载
|
|
|
|
+ *
|
|
*/
|
|
*/
|
|
private void filehHcfdDown(SolverBatchHcfd vo) throws Exception {
|
|
private void filehHcfdDown(SolverBatchHcfd vo) throws Exception {
|
|
- String boundaryFileId= vo.getBoundaryFileId();
|
|
|
|
- String boundaryName =vo.getBoundaryName();
|
|
|
|
- String gridFileId =vo.getGridFileId();
|
|
|
|
- String gridName =vo.getGridName();
|
|
|
|
- String nmlFileId =vo.getNmlFileId();
|
|
|
|
- //删除历史
|
|
|
|
- FileUtil.deleteDir(hcfdWorkDir+"/"+vo.getNmlId());
|
|
|
|
- String gridFristName =gridName.split("\\.")[0];
|
|
|
|
- //创建文件夹
|
|
|
|
- File workerDir =new File(hcfdWorkDir+"/"+vo.getNmlId());
|
|
|
|
- if(!workerDir.isDirectory()) {
|
|
|
|
|
|
+ String boundaryFileId = vo.getBoundaryFileId();
|
|
|
|
+ String boundaryName = vo.getBoundaryName();
|
|
|
|
+ String gridFileId = vo.getGridFileId();
|
|
|
|
+ String gridName = vo.getGridName();
|
|
|
|
+ String nmlFileId = vo.getNmlFileId();
|
|
|
|
+ // 删除历史
|
|
|
|
+ FileUtil.deleteDir(hcfdWorkDir + "/" + vo.getNmlId());
|
|
|
|
+ String gridFristName = gridName.split("\\.")[0];
|
|
|
|
+ // 创建文件夹
|
|
|
|
+ File workerDir = new File(hcfdWorkDir + "/" + vo.getNmlId());
|
|
|
|
+ if (!workerDir.isDirectory()) {
|
|
workerDir.mkdirs();
|
|
workerDir.mkdirs();
|
|
}
|
|
}
|
|
- File workerDataIn =new File(hcfdWorkDir+"/"+vo.getNmlId()+"/"+gridFristName+"/"+"data_in");
|
|
|
|
- if(!workerDataIn.isDirectory()) {
|
|
|
|
|
|
+ File workerDataIn = new File(hcfdWorkDir + "/" + vo.getNmlId() + "/" + gridFristName + "/" + "data_in");
|
|
|
|
+ if (!workerDataIn.isDirectory()) {
|
|
workerDataIn.mkdirs();
|
|
workerDataIn.mkdirs();
|
|
}
|
|
}
|
|
- File workerDataDataout =new File(hcfdWorkDir+"/"+vo.getNmlId()+"/"+gridFristName+"/test/"+"data_out");
|
|
|
|
- if(!workerDataDataout.isDirectory()) {
|
|
|
|
|
|
+ File workerDataDataout = new File(
|
|
|
|
+ hcfdWorkDir + "/" + vo.getNmlId() + "/" + gridFristName + "/test/" + "data_out");
|
|
|
|
+ if (!workerDataDataout.isDirectory()) {
|
|
workerDataDataout.mkdirs();
|
|
workerDataDataout.mkdirs();
|
|
- }
|
|
|
|
-
|
|
|
|
- fileDown(gridFileId, workerDataIn+"/"+gridName);
|
|
|
|
- fileDown(boundaryFileId, workerDataIn+"/"+boundaryName);
|
|
|
|
- fileDown(nmlFileId,hcfdWorkDir+"/"+vo.getNmlId()+"/"+gridFristName+"/test/hcfd.nml");
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ fileDown(gridFileId, workerDataIn + "/" + gridName);
|
|
|
|
+ fileDown(boundaryFileId, workerDataIn + "/" + boundaryName);
|
|
|
|
+ fileDown(nmlFileId, hcfdWorkDir + "/" + vo.getNmlId() + "/" + gridFristName + "/test/hcfd.nml");
|
|
}
|
|
}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
- * 文件下载
|
|
|
|
- *
|
|
|
|
|
|
+ * 文件下载
|
|
|
|
+ *
|
|
*/
|
|
*/
|
|
- private void fileDown(String fileId,String saveFilePath) throws Exception {
|
|
|
|
- String downUrl=url+"?channelNo=service&transCode=B00022&clientToken=e47b87eec69545559d1e81e56626da68&id="+fileId;
|
|
|
|
- HttpDownload.download(downUrl, saveFilePath);
|
|
|
|
|
|
+ private void fileDown(String fileId, String saveFilePath) throws Exception {
|
|
|
|
+ String downUrl = url + "?channelNo=service&transCode=B00022&clientToken=e47b87eec69545559d1e81e56626da68&id="
|
|
|
|
+ + fileId;
|
|
|
|
+ HttpDownload.download(downUrl, saveFilePath);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 任务状态为执行中
|
|
|
|
- *
|
|
|
|
|
|
+ * 任务状态为执行中
|
|
|
|
+ *
|
|
*/
|
|
*/
|
|
@Async
|
|
@Async
|
|
- private void jobStateLine(String nmlId,String solverIp) throws Exception {
|
|
|
|
- Map<String, String> paramMap=new HashMap<>();
|
|
|
|
|
|
+ private void jobStateLine(String nmlId, String solverIp) throws Exception {
|
|
|
|
+ Map<String, String> paramMap = new HashMap<>();
|
|
paramMap.put("channelNo", "service");
|
|
paramMap.put("channelNo", "service");
|
|
paramMap.put("clientToken", "e47b87eec69545559d1e81e56626da68");
|
|
paramMap.put("clientToken", "e47b87eec69545559d1e81e56626da68");
|
|
paramMap.put("transCode", "SBH011");
|
|
paramMap.put("transCode", "SBH011");
|
|
paramMap.put("nmlId", nmlId);
|
|
paramMap.put("nmlId", nmlId);
|
|
paramMap.put("solverIp", solverIp);
|
|
paramMap.put("solverIp", solverIp);
|
|
- paramMap.put("userId","5f06c8bc77234f969d13e160b54c27e3");
|
|
|
|
- HttpUtils.doPost(url,"","",new HashMap<String, String>(),new HashMap<String, String>(),paramMap);
|
|
|
|
|
|
+ paramMap.put("userId", "5f06c8bc77234f969d13e160b54c27e3");
|
|
|
|
+ HttpUtils.doPost(url, "", "", new HashMap<String, String>(), new HashMap<String, String>(), paramMap);
|
|
}
|
|
}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
- * 任务状态为成功
|
|
|
|
|
|
+ * 任务状态为成功
|
|
*
|
|
*
|
|
*/
|
|
*/
|
|
@Async
|
|
@Async
|
|
private void jobStateSuccess(String nmlId) throws Exception {
|
|
private void jobStateSuccess(String nmlId) throws Exception {
|
|
- Map<String, String> paramMap=new HashMap<>();
|
|
|
|
|
|
+ Map<String, String> paramMap = new HashMap<>();
|
|
paramMap.put("channelNo", "service");
|
|
paramMap.put("channelNo", "service");
|
|
paramMap.put("clientToken", "e47b87eec69545559d1e81e56626da68");
|
|
paramMap.put("clientToken", "e47b87eec69545559d1e81e56626da68");
|
|
paramMap.put("transCode", "SBH009");
|
|
paramMap.put("transCode", "SBH009");
|
|
paramMap.put("nmlId", nmlId);
|
|
paramMap.put("nmlId", nmlId);
|
|
- paramMap.put("userId","5f06c8bc77234f969d13e160b54c27e3");
|
|
|
|
- HttpUtils.doPost(url,"","",new HashMap<String, String>(),new HashMap<String, String>(),paramMap);
|
|
|
|
|
|
+ paramMap.put("userId", "5f06c8bc77234f969d13e160b54c27e3");
|
|
|
|
+ HttpUtils.doPost(url, "", "", new HashMap<String, String>(), new HashMap<String, String>(), paramMap);
|
|
}
|
|
}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
- * 任务状态为失败
|
|
|
|
|
|
+ * 任务状态为失败
|
|
*
|
|
*
|
|
*/
|
|
*/
|
|
@Async
|
|
@Async
|
|
private void jobStateError(String nmlId) throws Exception {
|
|
private void jobStateError(String nmlId) throws Exception {
|
|
- Map<String, String> paramMap=new HashMap<>();
|
|
|
|
|
|
+ Map<String, String> paramMap = new HashMap<>();
|
|
paramMap.put("channelNo", "service");
|
|
paramMap.put("channelNo", "service");
|
|
paramMap.put("clientToken", "e47b87eec69545559d1e81e56626da68");
|
|
paramMap.put("clientToken", "e47b87eec69545559d1e81e56626da68");
|
|
paramMap.put("transCode", "SBH010");
|
|
paramMap.put("transCode", "SBH010");
|
|
paramMap.put("nmlId", nmlId);
|
|
paramMap.put("nmlId", nmlId);
|
|
- paramMap.put("userId","5f06c8bc77234f969d13e160b54c27e3");
|
|
|
|
- HttpUtils.doPost(url,"","",new HashMap<String, String>(),new HashMap<String, String>(),paramMap);
|
|
|
|
|
|
+ paramMap.put("userId", "5f06c8bc77234f969d13e160b54c27e3");
|
|
|
|
+ HttpUtils.doPost(url, "", "", new HashMap<String, String>(), new HashMap<String, String>(), paramMap);
|
|
}
|
|
}
|
|
- public boolean isWait(String nmlId) {//挂起任务 不执行
|
|
|
|
- Map<String, String> paramMap=new HashMap<>();
|
|
|
|
|
|
+
|
|
|
|
+ public boolean isWait(String nmlId) {// 挂起任务 不执行
|
|
|
|
+ Map<String, String> paramMap = new HashMap<>();
|
|
paramMap.put("channelNo", "service");
|
|
paramMap.put("channelNo", "service");
|
|
paramMap.put("clientToken", "e47b87eec69545559d1e81e56626da68");
|
|
paramMap.put("clientToken", "e47b87eec69545559d1e81e56626da68");
|
|
paramMap.put("transCode", "SBH014");
|
|
paramMap.put("transCode", "SBH014");
|
|
paramMap.put("nmlId", nmlId);
|
|
paramMap.put("nmlId", nmlId);
|
|
- paramMap.put("userId","5f06c8bc77234f969d13e160b54c27e3");
|
|
|
|
|
|
+ paramMap.put("userId", "5f06c8bc77234f969d13e160b54c27e3");
|
|
try {
|
|
try {
|
|
- HttpResponse response= HttpUtils.doPost(url,"","",new HashMap<String, String>(),new HashMap<String, String>(),paramMap);
|
|
|
|
- JSONObject jsonObject = JSONObject.fromObject(EntityUtils.toString(response.getEntity()));
|
|
|
|
|
|
+ HttpResponse response = HttpUtils.doPost(url, "", "", new HashMap<String, String>(),
|
|
|
|
+ new HashMap<String, String>(), paramMap);
|
|
|
|
+ JSONObject jsonObject = JSONObject.fromObject(EntityUtils.toString(response.getEntity()));
|
|
JSONObject result = JSONObject.fromObject(jsonObject.get("result"));
|
|
JSONObject result = JSONObject.fromObject(jsonObject.get("result"));
|
|
String state = String.valueOf(jsonObject.get("state"));
|
|
String state = String.valueOf(jsonObject.get("state"));
|
|
String returnCode = String.valueOf(jsonObject.get("returnCode"));
|
|
String returnCode = String.valueOf(jsonObject.get("returnCode"));
|
|
- if ("000000000".equals(returnCode)) {//调用成功
|
|
|
|
- if("3".equals(state)) {////挂起任务
|
|
|
|
- return true;
|
|
|
|
- }else{
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
- } else {//调用失败
|
|
|
|
|
|
+ if ("000000000".equals(returnCode)) {// 调用成功
|
|
|
|
+ if ("3".equals(state)) {//// 挂起任务
|
|
|
|
+ return true;
|
|
|
|
+ } else {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ } else {// 调用失败
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param youNumber
|
|
* @param youNumber
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public static String int2String(int youNumber) {
|
|
public static String int2String(int youNumber) {
|
|
- String str = String.format("%010d", youNumber);
|
|
|
|
- return str;
|
|
|
|
|
|
+ String str = String.format("%010d", youNumber);
|
|
|
|
+ return str;
|
|
}
|
|
}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 强制停止进程
|
|
* 强制停止进程
|
|
|
|
+ *
|
|
* @param jobId
|
|
* @param jobId
|
|
- * @throws InterruptedException
|
|
|
|
- * @throws IOException
|
|
|
|
|
|
+ * @throws InterruptedException
|
|
|
|
+ * @throws IOException
|
|
*/
|
|
*/
|
|
- public void solverStop(String nmlId) throws Exception{
|
|
|
|
- if(SolverHcfdOrderUtil.isWindows()) {//windows
|
|
|
|
- //winows
|
|
|
|
- }else {
|
|
|
|
-
|
|
|
|
- log.info("stop:: "+nmlId);
|
|
|
|
- Process p =null;
|
|
|
|
- Runtime runtime = Runtime.getRuntime();
|
|
|
|
- String[] command = { "/bin/sh", "-c", "ps -ef|grep "+nmlId+"|grep mpirun|awk '{print $2}'"};
|
|
|
|
|
|
+ public void solverStop(String nmlId) throws Exception {
|
|
|
|
+ if (SolverHcfdOrderUtil.isWindows()) {// windows
|
|
|
|
+ // winows
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ log.info("stop:: " + nmlId);
|
|
|
|
+ Process p = null;
|
|
|
|
+ Runtime runtime = Runtime.getRuntime();
|
|
|
|
+ String[] command = { "/bin/sh", "-c", "ps -ef|grep " + nmlId + "|grep mpirun|awk '{print $2}'" };
|
|
// String[] command = { "/bin/sh", "-c", "ps -ef|grep java |awk '{print $2}'"};
|
|
// String[] command = { "/bin/sh", "-c", "ps -ef|grep java |awk '{print $2}'"};
|
|
- log.info("ps -ef|grep "+nmlId+"|grep mpirun|awk '{print $2}'");
|
|
|
|
|
|
+ log.info("ps -ef|grep " + nmlId + "|grep mpirun|awk '{print $2}'");
|
|
// p= runtime.exec("ps -ef|grep "+nmlId+"|grep mpirun|awk '{print $2}'");
|
|
// p= runtime.exec("ps -ef|grep "+nmlId+"|grep mpirun|awk '{print $2}'");
|
|
- p= runtime.exec(command);
|
|
|
|
- InputStream fis = p.getInputStream();
|
|
|
|
- InputStreamReader isr = new InputStreamReader(fis);
|
|
|
|
- BufferedReader br = new BufferedReader(isr);
|
|
|
|
- String line = null;
|
|
|
|
- List<String> pids =new ArrayList<>();
|
|
|
|
- while ((line = br.readLine()) != null) {
|
|
|
|
- log.info(line);
|
|
|
|
- pids.add(line);
|
|
|
|
- }
|
|
|
|
- p.waitFor();
|
|
|
|
- for (String pid : pids) {
|
|
|
|
- log.info("kill -9 "+pid);
|
|
|
|
- p= runtime.exec("kill -9 "+pid);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ p = runtime.exec(command);
|
|
|
|
+ InputStream fis = p.getInputStream();
|
|
|
|
+ InputStreamReader isr = new InputStreamReader(fis);
|
|
|
|
+ BufferedReader br = new BufferedReader(isr);
|
|
|
|
+ String line = null;
|
|
|
|
+ List<String> pids = new ArrayList<>();
|
|
|
|
+ while ((line = br.readLine()) != null) {
|
|
|
|
+ log.info(line);
|
|
|
|
+ pids.add(line);
|
|
|
|
+ }
|
|
|
|
+ p.waitFor();
|
|
|
|
+ for (String pid : pids) {
|
|
|
|
+ log.info("kill -9 " + pid);
|
|
|
|
+ p = runtime.exec("kill -9 " + pid);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|