com.clickzetta.platform.flusher.AbstractTask Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of clickzetta-java Show documentation
Show all versions of clickzetta-java Show documentation
The java SDK for clickzetta's Lakehouse
package com.clickzetta.platform.flusher;
import com.clickzetta.platform.common.FlushTaskCallException;
import org.apache.commons.lang3.StringUtils;
import java.util.concurrent.CompletableFuture;
public abstract class AbstractTask implements Task {
protected CompletableFuture future = new CompletableFuture<>();
@Override
public CompletableFuture> getFuture() {
return future;
}
public void callPrepare() throws Exception {
// do nothing.
}
public abstract void callInternal() throws Exception;
@Override
public CompletableFuture> skipCall(Throwable t) {
if (t == null) {
future.complete(true);
} else {
future.completeExceptionally(t);
}
return future;
}
@Override
public CompletableFuture> call() {
try {
callPrepare();
callInternal();
} catch (Throwable t) {
StackTraceElement[] elements = Thread.currentThread().getStackTrace();
String errMsg = t + "\n" + StringUtils.join(elements, "\n ");
future.completeExceptionally(new FlushTaskCallException(errMsg));
}
return future;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy