|
|
@ -1,18 +1,19 @@ |
|
|
|
package com.arialyy.aria.core.command.normal; |
|
|
|
package com.arialyy.aria.core.command.normal; |
|
|
|
|
|
|
|
|
|
|
|
import com.arialyy.aria.core.AriaManager; |
|
|
|
import com.arialyy.aria.core.AriaManager; |
|
|
|
|
|
|
|
import com.arialyy.aria.core.download.DownloadEntity; |
|
|
|
|
|
|
|
import com.arialyy.aria.core.download.DownloadGroupEntity; |
|
|
|
import com.arialyy.aria.core.download.DownloadGroupTaskEntity; |
|
|
|
import com.arialyy.aria.core.download.DownloadGroupTaskEntity; |
|
|
|
import com.arialyy.aria.core.download.DownloadTaskEntity; |
|
|
|
import com.arialyy.aria.core.download.DownloadTaskEntity; |
|
|
|
import com.arialyy.aria.core.download.wrapper.DGTEWrapper; |
|
|
|
|
|
|
|
import com.arialyy.aria.core.download.wrapper.DTEWrapper; |
|
|
|
|
|
|
|
import com.arialyy.aria.core.inf.AbsTask; |
|
|
|
import com.arialyy.aria.core.inf.AbsTask; |
|
|
|
import com.arialyy.aria.core.inf.AbsTaskEntity; |
|
|
|
import com.arialyy.aria.core.inf.AbsTaskEntity; |
|
|
|
import com.arialyy.aria.core.inf.IEntity; |
|
|
|
import com.arialyy.aria.core.inf.IEntity; |
|
|
|
|
|
|
|
import com.arialyy.aria.core.manager.TEManager; |
|
|
|
import com.arialyy.aria.core.queue.DownloadGroupTaskQueue; |
|
|
|
import com.arialyy.aria.core.queue.DownloadGroupTaskQueue; |
|
|
|
import com.arialyy.aria.core.queue.DownloadTaskQueue; |
|
|
|
import com.arialyy.aria.core.queue.DownloadTaskQueue; |
|
|
|
import com.arialyy.aria.core.queue.UploadTaskQueue; |
|
|
|
import com.arialyy.aria.core.queue.UploadTaskQueue; |
|
|
|
|
|
|
|
import com.arialyy.aria.core.upload.UploadEntity; |
|
|
|
import com.arialyy.aria.core.upload.UploadTaskEntity; |
|
|
|
import com.arialyy.aria.core.upload.UploadTaskEntity; |
|
|
|
import com.arialyy.aria.core.upload.wrapper.UTEWrapper; |
|
|
|
|
|
|
|
import com.arialyy.aria.orm.DbEntity; |
|
|
|
import com.arialyy.aria.orm.DbEntity; |
|
|
|
import com.arialyy.aria.util.ALog; |
|
|
|
import com.arialyy.aria.util.ALog; |
|
|
|
import com.arialyy.aria.util.CommonUtil; |
|
|
|
import com.arialyy.aria.util.CommonUtil; |
|
|
@ -43,10 +44,10 @@ final class ResumeAllCmd<T extends AbsTaskEntity> extends AbsNormalCmd<T> { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if (isDownloadCmd) { |
|
|
|
if (isDownloadCmd) { |
|
|
|
resumeTask(findTaskData(1)); |
|
|
|
findTaskData(1); |
|
|
|
resumeTask(findTaskData(2)); |
|
|
|
findTaskData(2); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
resumeTask(findTaskData(3)); |
|
|
|
findTaskData(3); |
|
|
|
} |
|
|
|
} |
|
|
|
resumeWaitTask(); |
|
|
|
resumeWaitTask(); |
|
|
|
} |
|
|
|
} |
|
|
@ -56,43 +57,41 @@ final class ResumeAllCmd<T extends AbsTaskEntity> extends AbsNormalCmd<T> { |
|
|
|
* |
|
|
|
* |
|
|
|
* @param type {@code 1}单任务下载任务;{@code 2}任务组下载任务;{@code 3} 单任务上传任务 |
|
|
|
* @param type {@code 1}单任务下载任务;{@code 2}任务组下载任务;{@code 3} 单任务上传任务 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private List<AbsTaskEntity> findTaskData(int type) { |
|
|
|
private void findTaskData(int type) { |
|
|
|
List<AbsTaskEntity> tempList = new ArrayList<>(); |
|
|
|
|
|
|
|
if (type == 1) { |
|
|
|
if (type == 1) { |
|
|
|
List<DTEWrapper> wrappers = DbEntity.findRelationData(DTEWrapper.class, |
|
|
|
List<DownloadEntity> entities = |
|
|
|
"DownloadTaskEntity.isGroupTask=? and DownloadTaskEntity.state!=?", "false", "1"); |
|
|
|
DbEntity.findDatas(DownloadEntity.class, |
|
|
|
if (wrappers != null && !wrappers.isEmpty()) { |
|
|
|
"isGroupChild=? and state!=?", "false", "1"); |
|
|
|
for (DTEWrapper w : wrappers) { |
|
|
|
if (entities != null && !entities.isEmpty()) { |
|
|
|
tempList.add(w.taskEntity); |
|
|
|
for (DownloadEntity entity : entities) { |
|
|
|
|
|
|
|
resumeTask(TEManager.getInstance().getTEntity(DownloadTaskEntity.class, entity.getKey())); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (type == 2) { |
|
|
|
} else if (type == 2) { |
|
|
|
List<DGTEWrapper> wrappers = |
|
|
|
List<DownloadGroupEntity> entities = |
|
|
|
DbEntity.findRelationData(DGTEWrapper.class, "DownloadGroupTaskEntity.state!=?", "1"); |
|
|
|
DbEntity.findDatas(DownloadGroupEntity.class, "state!=?", "1"); |
|
|
|
if (wrappers != null && !wrappers.isEmpty()) { |
|
|
|
if (entities != null && !entities.isEmpty()) { |
|
|
|
for (DGTEWrapper w : wrappers) { |
|
|
|
for (DownloadGroupEntity entity : entities) { |
|
|
|
tempList.add(w.taskEntity); |
|
|
|
resumeTask( |
|
|
|
|
|
|
|
TEManager.getInstance().getGTEntity(DownloadGroupTaskEntity.class, entity.getUrls())); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (type == 3) { |
|
|
|
} else if (type == 3) { |
|
|
|
List<UTEWrapper> wrappers = |
|
|
|
List<UploadEntity> entities = |
|
|
|
DbEntity.findRelationData(UTEWrapper.class, "UploadTaskEntity.state!=?", "1"); |
|
|
|
DbEntity.findDatas(UploadEntity.class, "state!=?", "1"); |
|
|
|
if (wrappers != null && !wrappers.isEmpty()) { |
|
|
|
if (entities != null && !entities.isEmpty()) { |
|
|
|
for (UTEWrapper w : wrappers) { |
|
|
|
for (UploadEntity entity : entities) { |
|
|
|
tempList.add(w.taskEntity); |
|
|
|
resumeTask(TEManager.getInstance().getTEntity(UploadTaskEntity.class, entity.getKey())); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return tempList; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 恢复任务 |
|
|
|
* 恢复任务 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void resumeTask(List<AbsTaskEntity> taskList) { |
|
|
|
private void resumeTask(AbsTaskEntity te) { |
|
|
|
if (taskList != null && !taskList.isEmpty()) { |
|
|
|
if (te == null || te.getEntity() == null) return; |
|
|
|
for (AbsTaskEntity te : taskList) { |
|
|
|
|
|
|
|
if (te == null || te.getEntity() == null) continue; |
|
|
|
|
|
|
|
int state = te.getState(); |
|
|
|
int state = te.getState(); |
|
|
|
if (state == IEntity.STATE_STOP || state == IEntity.STATE_OTHER) { |
|
|
|
if (state == IEntity.STATE_STOP || state == IEntity.STATE_OTHER) { |
|
|
|
resumeEntity(te); |
|
|
|
resumeEntity(te); |
|
|
@ -104,8 +103,6 @@ final class ResumeAllCmd<T extends AbsTaskEntity> extends AbsNormalCmd<T> { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 处理等待状态的任务 |
|
|
|
* 处理等待状态的任务 |
|
|
@ -117,6 +114,13 @@ final class ResumeAllCmd<T extends AbsTaskEntity> extends AbsNormalCmd<T> { |
|
|
|
if (mQueue.getCurrentExePoolNum() < maxTaskNum) { |
|
|
|
if (mQueue.getCurrentExePoolNum() < maxTaskNum) { |
|
|
|
startTask(createTask(te)); |
|
|
|
startTask(createTask(te)); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
if (te instanceof DownloadTaskEntity) { |
|
|
|
|
|
|
|
mQueue = DownloadTaskQueue.getInstance(); |
|
|
|
|
|
|
|
} else if (te instanceof UploadTaskEntity) { |
|
|
|
|
|
|
|
mQueue = UploadTaskQueue.getInstance(); |
|
|
|
|
|
|
|
} else if (te instanceof DownloadGroupTaskEntity) { |
|
|
|
|
|
|
|
mQueue = DownloadGroupTaskQueue.getInstance(); |
|
|
|
|
|
|
|
} |
|
|
|
createTask(te); |
|
|
|
createTask(te); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -129,7 +133,8 @@ final class ResumeAllCmd<T extends AbsTaskEntity> extends AbsNormalCmd<T> { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void resumeEntity(AbsTaskEntity te) { |
|
|
|
private void resumeEntity(AbsTaskEntity te) { |
|
|
|
if (te instanceof DownloadTaskEntity) { |
|
|
|
if (te instanceof DownloadTaskEntity) { |
|
|
|
if (te.getRequestType() == AbsTaskEntity.D_FTP || te.getRequestType() == AbsTaskEntity.U_FTP) { |
|
|
|
if (te.getRequestType() == AbsTaskEntity.D_FTP |
|
|
|
|
|
|
|
|| te.getRequestType() == AbsTaskEntity.U_FTP) { |
|
|
|
te.setUrlEntity(CommonUtil.getFtpUrlInfo(te.getEntity().getKey())); |
|
|
|
te.setUrlEntity(CommonUtil.getFtpUrlInfo(te.getEntity().getKey())); |
|
|
|
} |
|
|
|
} |
|
|
|
mQueue = DownloadTaskQueue.getInstance(); |
|
|
|
mQueue = DownloadTaskQueue.getInstance(); |
|
|
|