Skip to content

Commit

Permalink
failover cluster make attribute name to be final
Browse files Browse the repository at this point in the history
  • Loading branch information
nytta committed Nov 25, 2018
1 parent 43658bb commit 5b1640b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,20 @@ public abstract class AbstractCluster<T> implements Cluster<T>, RegistrySubcribe

private LoadBalance loadBalance;

protected String name;
protected final String name;

/**
* should call setInterfaceClass, setConsumers, setLoadBalance method after AbstractCluster instance is created.
*/
public AbstractCluster() {

public AbstractCluster(String name) {
this.name = name;
}

public AbstractCluster(Class<T> interfaceClass, List<Consumer<T>> consumers, LoadBalance loadBalance) {
public AbstractCluster(String name, Class<T> interfaceClass, List<Consumer<T>> consumers, LoadBalance loadBalance) {
if (consumers == null || consumers.isEmpty()) {
throw new IllegalStateException("List<Consumer<T> consumers is null or empty.");
}
this.name = name;
this.interfaceClass = interfaceClass;
this.consumers = consumers;
this.loadBalance = loadBalance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ public class FailoverCluster<T> extends AbstractCluster<T>{
private int retryTime = 2;

public FailoverCluster() {
super.name = "failover";
super("failover");
}

public FailoverCluster(Class<T> interfaceClass, List<Consumer<T>> consumers, LoadBalance loadBalance) {
super(interfaceClass, consumers, loadBalance);
super.name = "failover";
super("failover", interfaceClass, consumers, loadBalance);
}

@Override
Expand Down

0 comments on commit 5b1640b

Please sign in to comment.