Builder of Aggregator.

This commit is contained in:
Chuanyi Li L
2018-08-02 17:36:22 +08:00
committed by Chuanyi Li
parent 1c245280c7
commit bd14848600

View File

@@ -4,6 +4,7 @@ import com.alibaba.otter.canal.protocol.CanalPacket;
import org.jboss.netty.channel.ChannelFuture;
import org.jboss.netty.channel.ChannelFutureListener;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
/**
@@ -39,4 +40,64 @@ public class ChannelFutureAggregator implements ChannelFutureListener {
Throwable t = future.getCause();
}
}
public static class ClientRequestResult {
private String dest;
private CanalPacket.PacketType type;
private int amount;
private int errorCode;
private ClientRequestResult() {}
private ClientRequestResult(Builder builder) {
this.dest = builder.dest;
this.type = builder.type;
this.amount = builder.amount;
this.errorCode = builder.errorCode;
}
private static class Builder {
private String dest;
private CanalPacket.PacketType type;
private int amount;
private int errorCode;
public Builder dest(String dest) {
this.dest = dest;
return this;
}
public Builder type(CanalPacket.PacketType type) {
this.type = type;
return this;
}
public Builder amount(int amount) {
this.amount = amount;
return this;
}
public Builder errorCode(int errorCode) {
this.errorCode = errorCode;
return this;
}
public Builder fromPrototype(ClientRequestResult prototype) {
dest = prototype.dest;
type = prototype.type;
amount = prototype.amount;
errorCode = prototype.errorCode;
return this;
}
public ClientRequestResult build() {
return new ClientRequestResult(this);
}
}
}
}