All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.aliyun.openservices.ots.internal.OTSExecutionContext Maven / Gradle / Ivy

Go to download

Aliyun Open Services SDK for Java Copyright (C) Alibaba Cloud Computing All rights reserved. 版权所有 (C)阿里云计算有限公司 http://www.aliyun.com

There is a newer version: 2.2.4
Show newest version
package com.aliyun.openservices.ots.internal;


import com.aliyun.openservices.ots.model.OTSBasicFuture;
import org.apache.http.concurrent.FutureCallback;

import java.util.concurrent.ScheduledExecutorService;

public class OTSExecutionContext {
    private Req request;
    private OTSBasicFuture future;
    private OTSTraceLogger traceLogger;
    private FutureCallback asyncClientCallback;
    private OTSRetryStrategy retryStrategy;
    private ScheduledExecutorService retryExecutor;
    private OTSCallable callable;
    protected int retries = 0;

    public OTSExecutionContext(Req request, OTSBasicFuture future, OTSTraceLogger traceLogger,
                               OTSRetryStrategy retryStrategy, ScheduledExecutorService retryExecutor) {
        this.request = request;
        this.future = future;
        this.traceLogger = traceLogger;
        this.retryStrategy = retryStrategy;
        this.retryExecutor = retryExecutor;
    }

    /**
     * asyncClientCallback的创建依赖OTSExecutionContext对象,所以这里要单独set, 且应在setRetryHandler之后。
     */
    public void setAsyncClientCallback(FutureCallback futureCallback) {
        this.asyncClientCallback = futureCallback;
    }

    public void setCallable(OTSCallable callable) {
        this.callable = callable;
    }

    public OTSCallable getCallable() {
        return this.callable;
    }

    public void retry(Exception ex) {
        retries++;
    }

    public void setRequest(Req request) {
        this.request = request;
    }

    public Req getRequest() {
        return this.request;
    }

    public OTSBasicFuture getFuture() {
        return this.future;
    }

    public OTSTraceLogger getTraceLogger() {
        return this.traceLogger;
    }

    public FutureCallback getAsyncClientCallback() {
        return asyncClientCallback;
    }

    public OTSRetryStrategy getRetryStrategy() {
        return retryStrategy;
    }

    public ScheduledExecutorService getRetryExecutor() {
        return retryExecutor;
    }

    public int getRetries() {
        return retries;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy