Search in sources :

Example 11 with ProgressListener

use of com.aliyun.oss.event.ProgressListener in project aliyun-oss-java-sdk by aliyun.

the class OSSUdfOperation method getUdfApplicationLog.

public UdfApplicationLog getUdfApplicationLog(GetUdfApplicationLogRequest getUdfApplicationLogRequest) throws OSSException, ClientException {
    assertParameterNotNull(getUdfApplicationLogRequest, "resizeUdfApplicationRequest");
    String udfName = getUdfApplicationLogRequest.getName();
    assertParameterNotNull(udfName, "udfName");
    ensureBucketNameValid(udfName);
    Map<String, String> params = new HashMap<String, String>();
    populateGetUdfApplicationLogParameters(params, getUdfApplicationLogRequest);
    RequestMessage request = new OSSRequestMessageBuilder(getInnerClient()).setEndpoint(getEndpoint()).setMethod(HttpMethod.GET).setParameters(params).setOriginalRequest(getUdfApplicationLogRequest).build();
    ProgressListener listener = getUdfApplicationLogRequest.getProgressListener();
    UdfApplicationLog udfApplicationLog = null;
    try {
        publishProgress(listener, ProgressEventType.TRANSFER_STARTED_EVENT);
        udfApplicationLog = doOperation(request, new GetUdfApplicationLogResponseParser(udfName), null, null, true);
        InputStream instream = udfApplicationLog.getLogContent();
        ProgressInputStream progressInputStream = new ProgressInputStream(instream, listener) {

            @Override
            protected void onEOF() {
                publishProgress(getListener(), ProgressEventType.TRANSFER_COMPLETED_EVENT);
            }
        };
        CRC64 crc = new CRC64();
        CheckedInputStream checkedInputstream = new CheckedInputStream(progressInputStream, crc);
        udfApplicationLog.setLogContent(checkedInputstream);
    } catch (RuntimeException e) {
        publishProgress(listener, ProgressEventType.TRANSFER_FAILED_EVENT);
        throw e;
    }
    return udfApplicationLog;
}
Also used : GetUdfApplicationLogResponseParser(com.aliyun.oss.internal.ResponseParsers.GetUdfApplicationLogResponseParser) CRC64(com.aliyun.oss.common.utils.CRC64) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ProgressInputStream(com.aliyun.oss.event.ProgressInputStream) CheckedInputStream(java.util.zip.CheckedInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) ProgressInputStream(com.aliyun.oss.event.ProgressInputStream) IOUtils.newRepeatableInputStream(com.aliyun.oss.common.utils.IOUtils.newRepeatableInputStream) InputStream(java.io.InputStream) CheckedInputStream(java.util.zip.CheckedInputStream) UdfApplicationLog(com.aliyun.oss.model.UdfApplicationLog) ProgressListener(com.aliyun.oss.event.ProgressListener) RequestMessage(com.aliyun.oss.common.comm.RequestMessage)

Aggregations

ProgressListener (com.aliyun.oss.event.ProgressListener)11 InputStream (java.io.InputStream)7 ProgressInputStream (com.aliyun.oss.event.ProgressInputStream)6 RequestMessage (com.aliyun.oss.common.comm.RequestMessage)5 IOUtils.newRepeatableInputStream (com.aliyun.oss.common.utils.IOUtils.newRepeatableInputStream)5 ByteArrayInputStream (java.io.ByteArrayInputStream)5 IOException (java.io.IOException)5 HashMap (java.util.HashMap)5 LinkedHashMap (java.util.LinkedHashMap)5 ExecutionException (java.util.concurrent.ExecutionException)4 CheckedInputStream (java.util.zip.CheckedInputStream)4 ClientException (com.aliyun.oss.ClientException)3 UploadPartResult (com.aliyun.oss.model.UploadPartResult)3 ArrayList (java.util.ArrayList)3 RepeatableFileInputStream (com.aliyun.oss.common.comm.io.RepeatableFileInputStream)2 CRC64 (com.aliyun.oss.common.utils.CRC64)2 LogUtils.logException (com.aliyun.oss.common.utils.LogUtils.logException)2 ExecutorService (java.util.concurrent.ExecutorService)2 Future (java.util.concurrent.Future)2 ResponseHandler (com.aliyun.oss.common.comm.ResponseHandler)1