Search in sources :

Example 1 with DataRetrieveException

use of com.alibaba.otter.node.etl.common.io.download.exception.DataRetrieveException in project otter by alibaba.

the class Aria2cDownLoadIntegration method testDownLoad_ok.

@Test
public void testDownLoad_ok() {
    DataRetriever retriever = new Aria2cRetriever("http://china.alibaba.com", tmp);
    try {
        retriever.connect();
        retriever.doRetrieve();
    } catch (DataRetrieveException ex) {
        retriever.abort();
    } finally {
        retriever.disconnect();
    }
}
Also used : Aria2cRetriever(com.alibaba.otter.node.etl.common.io.download.impl.aria2c.Aria2cRetriever) DataRetrieveException(com.alibaba.otter.node.etl.common.io.download.exception.DataRetrieveException) DataRetriever(com.alibaba.otter.node.etl.common.io.download.DataRetriever) Test(org.testng.annotations.Test) BaseOtterTest(com.alibaba.otter.node.etl.BaseOtterTest)

Example 2 with DataRetrieveException

use of com.alibaba.otter.node.etl.common.io.download.exception.DataRetrieveException in project otter by alibaba.

the class AbstractCommandDownload method download.

public void download() throws IOException {
    // 准备下载
    notifyStatusChange(DownloadStatus.CONNECTING);
    Exec.Result result = null;
    try {
        result = Exec.execute(cmd);
        if (false == this.isSuccess(result.getExitCode())) {
            aborted.set(true);
            notifyException(new DataRetrieveException(result.toString()));
            notifyStatusChange(DownloadStatus.EXCEPTION);
        } else {
            this.analyzeResult(result);
            this.notifyMessage(result.toString());
            if (aborted.get()) {
                // 中断
                notifyStatusChange(DownloadStatus.ABORT);
            } else if (paused.get()) {
                // 暂停
                notifyStatusChange(DownloadStatus.PAUSED);
            } else {
                // 下载完成
                notifyStatusChange(DownloadStatus.COMPLETE);
            }
        }
    } catch (Exception ex) {
        aborted.set(true);
        notifyException(new DataRetrieveException((result != null) ? ex.getMessage() + SystemUtils.LINE_SEPARATOR + result.toString() : ex.getMessage(), ex));
    }
}
Also used : Exec(com.alibaba.otter.shared.common.utils.cmd.Exec) DataRetrieveException(com.alibaba.otter.node.etl.common.io.download.exception.DataRetrieveException) IOException(java.io.IOException) DataRetrieveException(com.alibaba.otter.node.etl.common.io.download.exception.DataRetrieveException)

Example 3 with DataRetrieveException

use of com.alibaba.otter.node.etl.common.io.download.exception.DataRetrieveException in project otter by alibaba.

the class Aria2cDownLoadIntegration method testDownLoad_failed.

@Test
public void testDownLoad_failed() {
    DataRetriever retriever = new Aria2cRetriever("aaaaaaa/sssss", tmp);
    try {
        retriever.connect();
        retriever.doRetrieve();
    } catch (DataRetrieveException ex) {
        retriever.abort();
    } finally {
        retriever.disconnect();
    }
}
Also used : Aria2cRetriever(com.alibaba.otter.node.etl.common.io.download.impl.aria2c.Aria2cRetriever) DataRetrieveException(com.alibaba.otter.node.etl.common.io.download.exception.DataRetrieveException) DataRetriever(com.alibaba.otter.node.etl.common.io.download.DataRetriever) Test(org.testng.annotations.Test) BaseOtterTest(com.alibaba.otter.node.etl.BaseOtterTest)

Aggregations

DataRetrieveException (com.alibaba.otter.node.etl.common.io.download.exception.DataRetrieveException)3 BaseOtterTest (com.alibaba.otter.node.etl.BaseOtterTest)2 DataRetriever (com.alibaba.otter.node.etl.common.io.download.DataRetriever)2 Aria2cRetriever (com.alibaba.otter.node.etl.common.io.download.impl.aria2c.Aria2cRetriever)2 Test (org.testng.annotations.Test)2 Exec (com.alibaba.otter.shared.common.utils.cmd.Exec)1 IOException (java.io.IOException)1