|
@@ -1,5 +1,6 @@
|
|
|
package cn.reghao.autodop.dmaster.app.service.config.impl;
|
|
package cn.reghao.autodop.dmaster.app.service.config.impl;
|
|
|
|
|
|
|
|
|
|
+import cn.reghao.autodop.common.machine.Machine;
|
|
|
import cn.reghao.autodop.common.util.ByteConverter;
|
|
import cn.reghao.autodop.common.util.ByteConverter;
|
|
|
import cn.reghao.autodop.common.util.ByteType;
|
|
import cn.reghao.autodop.common.util.ByteType;
|
|
|
import cn.reghao.autodop.common.util.FileOps;
|
|
import cn.reghao.autodop.common.util.FileOps;
|
|
@@ -9,7 +10,7 @@ import cn.reghao.autodop.dmaster.app.model.po.config.build.BuildDir;
|
|
|
import cn.reghao.autodop.dmaster.app.model.po.config.build.LocalBuildDir;
|
|
import cn.reghao.autodop.dmaster.app.model.po.config.build.LocalBuildDir;
|
|
|
import cn.reghao.autodop.dmaster.app.service.config.BuildDirService;
|
|
import cn.reghao.autodop.dmaster.app.service.config.BuildDirService;
|
|
|
import cn.reghao.jdkutil.machine.Disk;
|
|
import cn.reghao.jdkutil.machine.Disk;
|
|
|
-import cn.reghao.jdkutil.machine.MachineId;
|
|
|
|
|
|
|
+import cn.reghao.jdkutil.machine.detail.DiskDetail;
|
|
|
import cn.reghao.jdkutil.result.Result;
|
|
import cn.reghao.jdkutil.result.Result;
|
|
|
import cn.reghao.jdkutil.result.ResultStatus;
|
|
import cn.reghao.jdkutil.result.ResultStatus;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -26,9 +27,11 @@ import java.util.Objects;
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
@Service
|
|
@Service
|
|
|
public class BuildDirServiceImpl implements BuildDirService {
|
|
public class BuildDirServiceImpl implements BuildDirService {
|
|
|
|
|
+ // TODO 将 machineId 设置为一个常量
|
|
|
private final BuildDirQuery buildDirQuery;
|
|
private final BuildDirQuery buildDirQuery;
|
|
|
private final BuildDirCrud buildDirCrud;
|
|
private final BuildDirCrud buildDirCrud;
|
|
|
private final ByteConverter converter;
|
|
private final ByteConverter converter;
|
|
|
|
|
+ private Disk disk = new Disk();
|
|
|
|
|
|
|
|
public BuildDirServiceImpl(BuildDirQuery buildDirQuery, BuildDirCrud buildDirCrud) {
|
|
public BuildDirServiceImpl(BuildDirQuery buildDirQuery, BuildDirCrud buildDirCrud) {
|
|
|
this.buildDirQuery = buildDirQuery;
|
|
this.buildDirQuery = buildDirQuery;
|
|
@@ -55,13 +58,13 @@ public class BuildDirServiceImpl implements BuildDirService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private BuildDir createLocalBuildDir(String localBuildDir) throws Exception {
|
|
private BuildDir createLocalBuildDir(String localBuildDir) throws Exception {
|
|
|
- Disk.DiskDetail diskDetail = Disk.diskDetail(localBuildDir);
|
|
|
|
|
|
|
+ DiskDetail diskDetail = disk.diskDetail(localBuildDir);
|
|
|
BuildDir buildDir = new BuildDir();
|
|
BuildDir buildDir = new BuildDir();
|
|
|
- buildDir.setMachineId(MachineId.id());
|
|
|
|
|
- buildDir.setMachineIpv4(MachineId.ipv4());
|
|
|
|
|
|
|
+ buildDir.setMachineId(Machine.ID);
|
|
|
|
|
+ buildDir.setMachineIpv4(Machine.IPV4);
|
|
|
buildDir.setDirPath(localBuildDir);
|
|
buildDir.setDirPath(localBuildDir);
|
|
|
buildDir.setMountedOn(diskDetail.getMountedOn());
|
|
buildDir.setMountedOn(diskDetail.getMountedOn());
|
|
|
- buildDir.setTotal(converter.convert(ByteType.Bytes, diskDetail.getSize()));
|
|
|
|
|
|
|
+ buildDir.setTotal(converter.convert(ByteType.Bytes, diskDetail.getTotal()));
|
|
|
buildDir.setUsed(converter.convertStr(ByteType.Bytes, ByteType.MiB, diskDetail.getUsed()));
|
|
buildDir.setUsed(converter.convertStr(ByteType.Bytes, ByteType.MiB, diskDetail.getUsed()));
|
|
|
buildDir.setAvail(converter.convertStr(ByteType.Bytes, ByteType.MiB, diskDetail.getAvail()));
|
|
buildDir.setAvail(converter.convertStr(ByteType.Bytes, ByteType.MiB, diskDetail.getAvail()));
|
|
|
buildDir.setIsDelete(false);
|
|
buildDir.setIsDelete(false);
|
|
@@ -98,7 +101,7 @@ public class BuildDirServiceImpl implements BuildDirService {
|
|
|
public void refresh(BuildDir buildDir) {
|
|
public void refresh(BuildDir buildDir) {
|
|
|
setLocalBuildDir(buildDir);
|
|
setLocalBuildDir(buildDir);
|
|
|
String dirPath = buildDir.getDirPath();
|
|
String dirPath = buildDir.getDirPath();
|
|
|
- Disk.DiskDetail diskDetail = Disk.diskDetail(dirPath);
|
|
|
|
|
|
|
+ DiskDetail diskDetail = disk.diskDetail(dirPath);
|
|
|
if (diskDetail != null) {
|
|
if (diskDetail != null) {
|
|
|
buildDir.setUsed(converter.convertStr(ByteType.Bytes, ByteType.MiB, diskDetail.getUsed()));
|
|
buildDir.setUsed(converter.convertStr(ByteType.Bytes, ByteType.MiB, diskDetail.getUsed()));
|
|
|
buildDir.setAvail(converter.convertStr(ByteType.Bytes, ByteType.MiB, diskDetail.getAvail()));
|
|
buildDir.setAvail(converter.convertStr(ByteType.Bytes, ByteType.MiB, diskDetail.getAvail()));
|
|
@@ -118,7 +121,7 @@ public class BuildDirServiceImpl implements BuildDirService {
|
|
|
String oldDirPath = oldBuildDir.getDirPath();
|
|
String oldDirPath = oldBuildDir.getDirPath();
|
|
|
String oldMountedOn = oldBuildDir.getMountedOn();
|
|
String oldMountedOn = oldBuildDir.getMountedOn();
|
|
|
String newDirPath = buildDir.getDirPath();
|
|
String newDirPath = buildDir.getDirPath();
|
|
|
- String newMountedOn = Disk.diskDetail(newDirPath).getMountedOn();
|
|
|
|
|
|
|
+ String newMountedOn = disk.diskDetail(newDirPath).getMountedOn();
|
|
|
|
|
|
|
|
if (newDirPath.equals(oldDirPath)) {
|
|
if (newDirPath.equals(oldDirPath)) {
|
|
|
return Result.result(ResultStatus.FAIL, "目录没有改变");
|
|
return Result.result(ResultStatus.FAIL, "目录没有改变");
|