|
|
@ -89,8 +89,7 @@ public class ThreadMoveData{
|
|
|
|
long nowTime = new Date().getTime();
|
|
|
|
long nowTime = new Date().getTime();
|
|
|
|
long timelong = nowTime - DateForm.string2DateBysecond(dataMove.getLastTime()).getTime();
|
|
|
|
long timelong = nowTime - DateForm.string2DateBysecond(dataMove.getLastTime()).getTime();
|
|
|
|
if (timelong > 1000*60*20) {
|
|
|
|
if (timelong > 1000*60*20) {
|
|
|
|
dataMove.setCompleteStatus("3");
|
|
|
|
doMd5(srcSizeTemp, dstSize, dataMove);
|
|
|
|
dataInfoMoveTmpDao.update(dataMove);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//正在上传的个数。
|
|
|
|
//正在上传的个数。
|
|
|
|
moveFileCurrNum++;
|
|
|
|
moveFileCurrNum++;
|
|
|
@ -129,36 +128,8 @@ public class ThreadMoveData{
|
|
|
|
if("1".equals(dataMove.getCompleteStatus()) && dataMove.getRate() > 0){
|
|
|
|
if("1".equals(dataMove.getCompleteStatus()) && dataMove.getRate() > 0){
|
|
|
|
//传输完毕:进行校验
|
|
|
|
//传输完毕:进行校验
|
|
|
|
if (realRate >= 100) {
|
|
|
|
if (realRate >= 100) {
|
|
|
|
int difSize = (int) (srcSizeTemp-dstSize);
|
|
|
|
//TODO
|
|
|
|
Thread.sleep(10*difSize);
|
|
|
|
doMd5(srcSizeTemp, dstSize, dataMove);
|
|
|
|
//TODO 查看当前拷贝目录进程是否结束?
|
|
|
|
|
|
|
|
// 进行MD5校验
|
|
|
|
|
|
|
|
int resl = check.checkoutMD5Folder(dataMove.getDataPath(), dataMove.getDstPath());
|
|
|
|
|
|
|
|
// 校验成功--则增加数据库记录
|
|
|
|
|
|
|
|
if(resl == 1){
|
|
|
|
|
|
|
|
// 判断 迁移数据的status是否改为 2
|
|
|
|
|
|
|
|
DataInfoEntityMoveTmp movetmp = dataInfoMoveTmpDao.findById(dataMove.getId());
|
|
|
|
|
|
|
|
if (null != movetmp && !"2".equals(movetmp.getCompleteStatus())) {
|
|
|
|
|
|
|
|
//校验成功--修改 数据库记录--
|
|
|
|
|
|
|
|
dataMove.setCompleteStatus("2");
|
|
|
|
|
|
|
|
dataMove.setLastTime(DateForm.date2StringBysecond(new Date()));
|
|
|
|
|
|
|
|
dataInfoMoveTmpDao.update(dataMove);
|
|
|
|
|
|
|
|
//TODO 新增 一条数据-到-dataInfo
|
|
|
|
|
|
|
|
DataInfoEntity data = (DataInfoEntity) Bean2MapUtils.convertMap(
|
|
|
|
|
|
|
|
DataInfoEntity.class, Bean2MapUtils.convertBean(dataMove));
|
|
|
|
|
|
|
|
data.setDataPath(dataMove.getDstPath());
|
|
|
|
|
|
|
|
data.setVolumeIp(dataMove.getDstVolumeIp());
|
|
|
|
|
|
|
|
data.setVolumePath(dataMove.getDstVolumePath());
|
|
|
|
|
|
|
|
data.setVolumeIp(dataMove.getVolumeIp());
|
|
|
|
|
|
|
|
data.setId(0);
|
|
|
|
|
|
|
|
dataInfoDao.save(data);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
// 3:表示 迁移失败
|
|
|
|
|
|
|
|
dataMove.setLastTime(DateForm.date2StringBysecond(new Date()));
|
|
|
|
|
|
|
|
dataMove.setCompleteStatus("3");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dataMove.setLastTime(DateForm.date2StringBysecond(new Date()));
|
|
|
|
dataMove.setLastTime(DateForm.date2StringBysecond(new Date()));
|
|
|
|
dataInfoMoveTmpDao.update(dataMove);
|
|
|
|
dataInfoMoveTmpDao.update(dataMove);
|
|
|
@ -178,15 +149,16 @@ public class ThreadMoveData{
|
|
|
|
if ("0".equals(next2move.getCompleteStatus())) {
|
|
|
|
if ("0".equals(next2move.getCompleteStatus())) {
|
|
|
|
//待迁移的数据 -- 开始迁移
|
|
|
|
//待迁移的数据 -- 开始迁移
|
|
|
|
// 末尾 含有 /
|
|
|
|
// 末尾 含有 /
|
|
|
|
Pattern pattern2 = Pattern.compile("\\/$");
|
|
|
|
Pattern pattern2 = Pattern.compile("\\d+\\/$");
|
|
|
|
String dstPath = next2move.getDataPath();
|
|
|
|
String dstPath = next2move.getDstPath();
|
|
|
|
Matcher matcher2 = pattern2.matcher(dstPath);
|
|
|
|
Matcher matcher2 = pattern2.matcher(dstPath);
|
|
|
|
//去掉 最后 的 / 符合
|
|
|
|
//去掉 最后 的 数字 +/ 符合
|
|
|
|
if (matcher2.find()) {
|
|
|
|
if (matcher2.find()) {
|
|
|
|
dstPath = dstPath.substring(0, dstPath.length()-1);
|
|
|
|
String removeStr = matcher2.group();
|
|
|
|
|
|
|
|
dstPath = dstPath.replace(removeStr, "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//数据迁移。
|
|
|
|
//数据迁移。
|
|
|
|
copy.copyFolder(dstPath+"/app", next2move.getDstPath());
|
|
|
|
copy.copyFolder(next2move.getDataPath(), dstPath);
|
|
|
|
// "1" :正在上传,0:等待 迁移, 2:成功 3:失败
|
|
|
|
// "1" :正在上传,0:等待 迁移, 2:成功 3:失败
|
|
|
|
next2move.setCompleteStatus("1");
|
|
|
|
next2move.setCompleteStatus("1");
|
|
|
|
next2move.setLastTime(DateForm.date2StringBysecond(new Date()));
|
|
|
|
next2move.setLastTime(DateForm.date2StringBysecond(new Date()));
|
|
|
@ -205,5 +177,44 @@ public class ThreadMoveData{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void doMd5(long srcSizeTemp, long dstSize, DataInfoEntityMoveTmp dataMove) throws Exception {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int difSize = (int) (srcSizeTemp-dstSize);
|
|
|
|
|
|
|
|
if (difSize < 1) {
|
|
|
|
|
|
|
|
difSize = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Thread.sleep(10*difSize);
|
|
|
|
|
|
|
|
//TODO 查看当前拷贝目录进程是否结束?
|
|
|
|
|
|
|
|
// 进行MD5校验
|
|
|
|
|
|
|
|
int resl = check.checkoutMD5Folder(dataMove.getDataPath(), dataMove.getDstPath());
|
|
|
|
|
|
|
|
// 校验成功--则增加数据库记录
|
|
|
|
|
|
|
|
if(resl == 1){
|
|
|
|
|
|
|
|
// 判断 迁移数据的status是否改为 2
|
|
|
|
|
|
|
|
DataInfoEntityMoveTmp movetmp = dataInfoMoveTmpDao.findById(dataMove.getId());
|
|
|
|
|
|
|
|
if (null != movetmp && !"2".equals(movetmp.getCompleteStatus())) {
|
|
|
|
|
|
|
|
//校验成功--修改 数据库记录--
|
|
|
|
|
|
|
|
dataMove.setCompleteStatus("2");
|
|
|
|
|
|
|
|
dataMove.setLastTime(DateForm.date2StringBysecond(new Date()));
|
|
|
|
|
|
|
|
dataInfoMoveTmpDao.update(dataMove);
|
|
|
|
|
|
|
|
//TODO 新增 一条数据-到-dataInfo
|
|
|
|
|
|
|
|
DataInfoEntity data = (DataInfoEntity) Bean2MapUtils.convertMap(
|
|
|
|
|
|
|
|
DataInfoEntity.class, Bean2MapUtils.convertBean(dataMove));
|
|
|
|
|
|
|
|
data.setDataPath(dataMove.getDstPath());
|
|
|
|
|
|
|
|
data.setVolumeIp(dataMove.getDstVolumeIp());
|
|
|
|
|
|
|
|
data.setVolumePath(dataMove.getDstVolumePath());
|
|
|
|
|
|
|
|
data.setVolumeIp(dataMove.getVolumeIp());
|
|
|
|
|
|
|
|
data.setId(0);
|
|
|
|
|
|
|
|
dataInfoDao.save(data);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
// 3:表示 迁移失败
|
|
|
|
|
|
|
|
dataMove.setLastTime(DateForm.date2StringBysecond(new Date()));
|
|
|
|
|
|
|
|
dataMove.setCompleteStatus("3");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|