diff --git a/server/src/main/java/com/alibaba/otter/canal/server/netty/listener/ChannelFutureAggregator.java b/server/src/main/java/com/alibaba/otter/canal/server/netty/listener/ChannelFutureAggregator.java index aa9b0da3..e3f60dca 100644 --- a/server/src/main/java/com/alibaba/otter/canal/server/netty/listener/ChannelFutureAggregator.java +++ b/server/src/main/java/com/alibaba/otter/canal/server/netty/listener/ChannelFutureAggregator.java @@ -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); + } + } + } }