|
@@ -94,72 +94,8 @@ public class DockerExe {
|
|
// 使用 ResultCallback.Adapter 处理日志
|
|
// 使用 ResultCallback.Adapter 处理日志
|
|
logContainerCmd.exec(logsexe).awaitCompletion();
|
|
logContainerCmd.exec(logsexe).awaitCompletion();
|
|
}
|
|
}
|
|
- public static void runMdo(String pid) {
|
|
|
|
- DockerClientConfig config = DefaultDockerClientConfig.createDefaultConfigBuilder()
|
|
|
|
- .withDockerHost(DOCKERHOST) // 设置 Docker 主机地址
|
|
|
|
- .withDockerTlsVerify(false) // 启用 TLS 验证
|
|
|
|
- .withApiVersion(APIVERSION) // 设置 API 版本
|
|
|
|
- .build();
|
|
|
|
- DockerHttpClient httpClient = new ApacheDockerHttpClient.Builder()
|
|
|
|
- .dockerHost(config.getDockerHost())
|
|
|
|
- .sslConfig(config.getSSLConfig())
|
|
|
|
- .build();
|
|
|
|
- DockerClient dockerClient = DockerClientBuilder.getInstance(config)
|
|
|
|
- .withDockerHttpClient(httpClient)
|
|
|
|
- .build();
|
|
|
|
-
|
|
|
|
- Mount cephfsVMount = new Mount()
|
|
|
|
- .withType(MountType.BIND)
|
|
|
|
- .withSource("/cephfs/mdo/")
|
|
|
|
- .withTarget("/cephfs/mdo/")
|
|
|
|
- .withReadOnly(false);
|
|
|
|
- Mount sitePackages = new Mount()
|
|
|
|
- .withType(MountType.BIND)
|
|
|
|
- .withSource("/home/xgd/site-packages/")
|
|
|
|
- .withTarget("/opt/miniconda3/envs/surromdao/lib/python3.10/site-packages/")
|
|
|
|
- .withReadOnly(false);
|
|
|
|
- Mount outMount = new Mount()
|
|
|
|
- .withType(MountType.BIND)
|
|
|
|
- .withSource("/cephfs/mdo/"+pid +"/out/")
|
|
|
|
- .withTarget("/workspace/outdata/")
|
|
|
|
- .withReadOnly(false);
|
|
|
|
- Mount runMount = new Mount()
|
|
|
|
- .withType(MountType.BIND)
|
|
|
|
- .withSource("/cephfs/mdo/"+pid +"/in/run.py")
|
|
|
|
- .withTarget("/workspace/run.py")
|
|
|
|
- .withReadOnly(false);
|
|
|
|
- Mount nsga2_history1 = new Mount()
|
|
|
|
- .withType(MountType.BIND)
|
|
|
|
- .withSource("/cephfs/mdo/"+pid +"/out/nsga2_history1.txt")
|
|
|
|
- .withTarget("/workspace/nsga2_history1.txt")
|
|
|
|
- .withReadOnly(false);
|
|
|
|
- Mount nsga2_history2 = new Mount()
|
|
|
|
- .withType(MountType.BIND)
|
|
|
|
- .withSource("/cephfs/mdo/"+pid +"/out/nsga2_history2.txt")
|
|
|
|
- .withTarget("/workspace/nsga2_history2.txt")
|
|
|
|
- .withReadOnly(false);
|
|
|
|
-
|
|
|
|
- List<Mount> am =new ArrayList<>();
|
|
|
|
- am.add(cephfsVMount);
|
|
|
|
- am.add(sitePackages);
|
|
|
|
- am.add(outMount);
|
|
|
|
- am.add(runMount);
|
|
|
|
- am.add(nsga2_history1);
|
|
|
|
- am.add(nsga2_history2);
|
|
|
|
- //创建容器
|
|
|
|
- CreateContainerResponse container = dockerClient
|
|
|
|
- .createContainerCmd("xgd:2.0")//镜像名称
|
|
|
|
- .withName(pid)//容器名称
|
|
|
|
- .withHostConfig(
|
|
|
|
- HostConfig.newHostConfig()
|
|
|
|
- .withMounts(am)
|
|
|
|
- ).exec();
|
|
|
|
- dockerClient.startContainerCmd(container.getId()).exec();
|
|
|
|
- System.out.println("容器启动成功,ID: " + container.getId());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
|
|
- public static void runMdo3(String pid) {
|
|
|
|
|
|
+ public static void run(String pid) {
|
|
DockerClientConfig config = DefaultDockerClientConfig.createDefaultConfigBuilder()
|
|
DockerClientConfig config = DefaultDockerClientConfig.createDefaultConfigBuilder()
|
|
.withDockerHost(DOCKERHOST) // 设置 Docker 主机地址
|
|
.withDockerHost(DOCKERHOST) // 设置 Docker 主机地址
|
|
.withDockerTlsVerify(false) // 启用 TLS 验证
|
|
.withDockerTlsVerify(false) // 启用 TLS 验证
|
|
@@ -175,216 +111,25 @@ public class DockerExe {
|
|
|
|
|
|
Mount wokerMount = new Mount()
|
|
Mount wokerMount = new Mount()
|
|
.withType(MountType.BIND)
|
|
.withType(MountType.BIND)
|
|
- .withSource("/cephfs/mdo/"+pid+"/in/")
|
|
|
|
- .withTarget("/cephfs/mdo/"+pid+"/in/")
|
|
|
|
|
|
+ .withSource("/cephfs/es/"+pid)
|
|
|
|
+ .withTarget("/cephfs/es/"+pid)
|
|
.withReadOnly(false);
|
|
.withReadOnly(false);
|
|
List<Mount> am =new ArrayList<>();
|
|
List<Mount> am =new ArrayList<>();
|
|
am.add(wokerMount);
|
|
am.add(wokerMount);
|
|
|
|
|
|
//创建容器
|
|
//创建容器
|
|
CreateContainerResponse container = dockerClient
|
|
CreateContainerResponse container = dockerClient
|
|
- .createContainerCmd("surromdao:2.0")//镜像名称
|
|
|
|
|
|
+ .createContainerCmd("es:1.0")//镜像名称
|
|
.withName(pid)//容器名称
|
|
.withName(pid)//容器名称
|
|
.withHostConfig(
|
|
.withHostConfig(
|
|
HostConfig.newHostConfig()
|
|
HostConfig.newHostConfig()
|
|
.withMounts(am)
|
|
.withMounts(am)
|
|
- ).withCmd("bash", "-c", "source /home/mdo/aeroelastic.sh && cd /cephfs/mdo/"+pid+"/in && conda activate surromdao && mpiexec -n 3 python run.py")
|
|
|
|
|
|
+ ).withCmd("bash", "-c", "export LD_LIBRARY_PATH=/home/es/bin:$LD_LIBRARY_PATH && pipenet /cephfs/es/"+pid+"/Calculate")
|
|
.exec();
|
|
.exec();
|
|
dockerClient.startContainerCmd(container.getId()).exec();
|
|
dockerClient.startContainerCmd(container.getId()).exec();
|
|
System.out.println("容器启动成功,ID: " + container.getId());
|
|
System.out.println("容器启动成功,ID: " + container.getId());
|
|
}
|
|
}
|
|
|
|
|
|
- public static void runMdo2(String pid) {
|
|
|
|
- DockerClientConfig config = DefaultDockerClientConfig.createDefaultConfigBuilder()
|
|
|
|
- .withDockerHost(DOCKERHOST) // 设置 Docker 主机地址
|
|
|
|
- .withDockerTlsVerify(false) // 启用 TLS 验证
|
|
|
|
- .withApiVersion(APIVERSION) // 设置 API 版本
|
|
|
|
- .build();
|
|
|
|
- DockerHttpClient httpClient = new ApacheDockerHttpClient.Builder()
|
|
|
|
- .dockerHost(config.getDockerHost())
|
|
|
|
- .sslConfig(config.getSSLConfig())
|
|
|
|
- .build();
|
|
|
|
- DockerClient dockerClient = DockerClientBuilder.getInstance(config)
|
|
|
|
- .withDockerHttpClient(httpClient)
|
|
|
|
- .build();
|
|
|
|
-
|
|
|
|
- Mount wokerMount = new Mount()
|
|
|
|
- .withType(MountType.BIND)
|
|
|
|
- .withSource("/cephfs/mdo/"+pid+"/in/")
|
|
|
|
- .withTarget("/cephfs/mdo/"+pid+"/in/")
|
|
|
|
- .withReadOnly(false);
|
|
|
|
- List<Mount> am =new ArrayList<>();
|
|
|
|
- am.add(wokerMount);
|
|
|
|
|
|
|
|
- //创建容器
|
|
|
|
- CreateContainerResponse container = dockerClient
|
|
|
|
- .createContainerCmd("surromdao:1.0")//镜像名称
|
|
|
|
- .withName(pid)//容器名称
|
|
|
|
- .withHostConfig(
|
|
|
|
- HostConfig.newHostConfig()
|
|
|
|
- .withMounts(am)
|
|
|
|
- ).withCmd("bash", "-c", "source /home/mdo/aeroelastic.sh && cd /cephfs/mdo/"+pid+"/in && mpiexec -n 1 python run.py")
|
|
|
|
- .exec();
|
|
|
|
- dockerClient.startContainerCmd(container.getId()).exec();
|
|
|
|
- System.out.println("容器启动成功,ID: " + container.getId());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- public static void cgnsToJson(SysFile file) throws Exception {
|
|
|
|
- DockerClientConfig config = DefaultDockerClientConfig.createDefaultConfigBuilder()
|
|
|
|
- .withDockerHost(DOCKERHOST) // 设置 Docker 主机地址
|
|
|
|
- .withDockerTlsVerify(false) // 启用 TLS 验证
|
|
|
|
- .withApiVersion(APIVERSION) // 设置 API 版本
|
|
|
|
- .build();
|
|
|
|
- DockerHttpClient httpClient = new ApacheDockerHttpClient.Builder()
|
|
|
|
- .dockerHost(config.getDockerHost())
|
|
|
|
- .sslConfig(config.getSSLConfig())
|
|
|
|
- .build();
|
|
|
|
- DockerClient dockerClient = DockerClientBuilder.getInstance(config)
|
|
|
|
- .withDockerHttpClient(httpClient)
|
|
|
|
- .build();
|
|
|
|
|
|
|
|
- Path path = Paths.get(XIFileUtils.getRootPathStr()+"/"+file.getFilepath());
|
|
|
|
- // 获取文件夹路径
|
|
|
|
- String directory = path.getParent().toString();
|
|
|
|
- Mount wokerMount = new Mount()
|
|
|
|
- .withType(MountType.BIND)
|
|
|
|
- .withSource(directory)
|
|
|
|
- .withTarget(directory)
|
|
|
|
- .withReadOnly(false);
|
|
|
|
- List<Mount> am =new ArrayList<>();
|
|
|
|
- am.add(wokerMount);
|
|
|
|
- String hdfFile =directory+"/"+file.getFilename().replace(".cgns","_hdf5.cgns");
|
|
|
|
- File hdf =new File(hdfFile);
|
|
|
|
- if(!hdf.exists()){
|
|
|
|
- hdf.createNewFile();
|
|
|
|
- }
|
|
|
|
- String jsonFile =directory+"/"+file.getFilename().replace(".cgns","_data.json");
|
|
|
|
- File json =new File(jsonFile);
|
|
|
|
- if(!json.exists()){
|
|
|
|
- json.createNewFile();
|
|
|
|
- }
|
|
|
|
- XIFileUtils.saveUploadFiles(hdfFile, "uid","hdf5",file.getId());
|
|
|
|
- XIFileUtils.saveUploadFiles(jsonFile, "uid","json",file.getId());
|
|
|
|
- //创建容器
|
|
|
|
- CreateContainerResponse container = dockerClient
|
|
|
|
- .createContainerCmd("cgnsconver:1.0")//镜像名称
|
|
|
|
- .withName(file.getId())//容器名称
|
|
|
|
- .withHostConfig(
|
|
|
|
- HostConfig.newHostConfig()
|
|
|
|
- .withMounts(am)
|
|
|
|
- ).withCmd("bash", "-c", "source /root/miniconda3/etc/profile.d/conda.sh" +
|
|
|
|
- " && conda activate pycgns-env" +
|
|
|
|
- " && cd /home/python/mdo/" +
|
|
|
|
- " && python cgnsConver.py" +
|
|
|
|
- " "+XIFileUtils.getRootPathStr()+"/"+file.getFilepath() +
|
|
|
|
- " " +hdfFile+
|
|
|
|
- " " +jsonFile)
|
|
|
|
- .exec();
|
|
|
|
- dockerClient.startContainerCmd(container.getId()).exec();
|
|
|
|
- System.out.println("容器启动成功,ID: " + container.getId());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public static void bdfToJson(SysFile file) throws Exception {
|
|
|
|
- DockerClientConfig config = DefaultDockerClientConfig.createDefaultConfigBuilder()
|
|
|
|
- .withDockerHost(DOCKERHOST) // 设置 Docker 主机地址
|
|
|
|
- .withDockerTlsVerify(false) // 启用 TLS 验证
|
|
|
|
- .withApiVersion(APIVERSION) // 设置 API 版本
|
|
|
|
- .build();
|
|
|
|
- DockerHttpClient httpClient = new ApacheDockerHttpClient.Builder()
|
|
|
|
- .dockerHost(config.getDockerHost())
|
|
|
|
- .sslConfig(config.getSSLConfig())
|
|
|
|
- .build();
|
|
|
|
- DockerClient dockerClient = DockerClientBuilder.getInstance(config)
|
|
|
|
- .withDockerHttpClient(httpClient)
|
|
|
|
- .build();
|
|
|
|
-
|
|
|
|
- Path path = Paths.get(XIFileUtils.getRootPathStr()+"/"+file.getFilepath());
|
|
|
|
- // 获取文件夹路径
|
|
|
|
- String directory = path.getParent().toString();
|
|
|
|
- Mount wokerMount = new Mount()
|
|
|
|
- .withType(MountType.BIND)
|
|
|
|
- .withSource(directory)
|
|
|
|
- .withTarget(directory)
|
|
|
|
- .withReadOnly(false);
|
|
|
|
- List<Mount> am =new ArrayList<>();
|
|
|
|
- am.add(wokerMount);
|
|
|
|
-
|
|
|
|
- String jsonFile =directory+"/"+file.getFilename().replace(".bdf","_data.json");
|
|
|
|
- File json =new File(jsonFile);
|
|
|
|
- if(!json.exists()){
|
|
|
|
- json.createNewFile();
|
|
|
|
- }
|
|
|
|
- XIFileUtils.saveUploadFiles(jsonFile, "uid","json",file.getId());
|
|
|
|
- //创建容器
|
|
|
|
- CreateContainerResponse container = dockerClient
|
|
|
|
- .createContainerCmd("cgnsconver:1.0")//镜像名称
|
|
|
|
- .withName(file.getId())//容器名称
|
|
|
|
- .withHostConfig(
|
|
|
|
- HostConfig.newHostConfig()
|
|
|
|
- .withMounts(am)
|
|
|
|
- ).withCmd("bash", "-c", "source /root/miniconda3/etc/profile.d/conda.sh" +
|
|
|
|
- " && conda activate pycgns-env" +
|
|
|
|
- " && cd /home/python/mdo/" +
|
|
|
|
- " && python bdfConver.py" +
|
|
|
|
- " "+XIFileUtils.getRootPathStr()+"/"+file.getFilepath() +
|
|
|
|
- " " +jsonFile)
|
|
|
|
- .exec();
|
|
|
|
- dockerClient.startContainerCmd(container.getId()).exec();
|
|
|
|
- System.out.println("容器启动成功,ID: " + container.getId());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public static void main(String[] args) {
|
|
|
|
- stopDocker("6cb37eea2845457ca17ba6441804af43");
|
|
|
|
- runMdo2("6cb37eea2845457ca17ba6441804af43");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public static void pltToJson(SysFile file) throws Exception {
|
|
|
|
- DockerClientConfig config = DefaultDockerClientConfig.createDefaultConfigBuilder()
|
|
|
|
- .withDockerHost(DOCKERHOST) // 设置 Docker 主机地址
|
|
|
|
- .withDockerTlsVerify(false) // 启用 TLS 验证
|
|
|
|
- .withApiVersion(APIVERSION) // 设置 API 版本
|
|
|
|
- .build();
|
|
|
|
- DockerHttpClient httpClient = new ApacheDockerHttpClient.Builder()
|
|
|
|
- .dockerHost(config.getDockerHost())
|
|
|
|
- .sslConfig(config.getSSLConfig())
|
|
|
|
- .build();
|
|
|
|
- DockerClient dockerClient = DockerClientBuilder.getInstance(config)
|
|
|
|
- .withDockerHttpClient(httpClient)
|
|
|
|
- .build();
|
|
|
|
-
|
|
|
|
- Path path = Paths.get(XIFileUtils.getRootPathStr()+"/"+file.getFilepath());
|
|
|
|
- // 获取文件夹路径
|
|
|
|
- String directory = path.getParent().toString();
|
|
|
|
- Mount wokerMount = new Mount()
|
|
|
|
- .withType(MountType.BIND)
|
|
|
|
- .withSource(directory)
|
|
|
|
- .withTarget(directory)
|
|
|
|
- .withReadOnly(false);
|
|
|
|
- List<Mount> am =new ArrayList<>();
|
|
|
|
- am.add(wokerMount);
|
|
|
|
-
|
|
|
|
- String plth5File =directory+"/"+file.getFilename().replace(".plt","plt_data.h5");
|
|
|
|
- File json =new File(plth5File);
|
|
|
|
- if(!json.exists()){
|
|
|
|
- json.createNewFile();
|
|
|
|
- }
|
|
|
|
- XIFileUtils.saveUploadFiles(plth5File, "uid","hdf5",file.getId());
|
|
|
|
- //创建容器
|
|
|
|
- CreateContainerResponse container = dockerClient
|
|
|
|
- .createContainerCmd("cgnsconver:1.0")//镜像名称
|
|
|
|
- .withName(file.getId())//容器名称
|
|
|
|
- .withHostConfig(
|
|
|
|
- HostConfig.newHostConfig()
|
|
|
|
- .withMounts(am)
|
|
|
|
- ).withCmd("bash", "-c", "source /root/miniconda3/etc/profile.d/conda.sh" +
|
|
|
|
- " && conda activate pycgns-env" +
|
|
|
|
- " && cd /home/python/mdo/" +
|
|
|
|
- " && python pltConver.py" +
|
|
|
|
- " "+XIFileUtils.getRootPathStr()+"/"+file.getFilepath() +
|
|
|
|
- " " +plth5File)
|
|
|
|
- .exec();
|
|
|
|
- dockerClient.startContainerCmd(container.getId()).exec();
|
|
|
|
- System.out.println("容器启动成功,ID: " + container.getId());
|
|
|
|
- }
|
|
|
|
}
|
|
}
|