Skip to content
This repository has been archived by the owner on May 30, 2022. It is now read-only.

Hystrix switcher #137

Merged
merged 5 commits into from
Dec 29, 2018
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -118,6 +118,8 @@ public class SofaBootRpcProperties {

private String consumerRepeatedReferenceLimit;

private String enableHystrix;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does enableHystrix means the key is com.alipay.sofa.rpc.enable.hystrix ?

I think com.alipay.sofa.rpc.hystrix.enable is better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be com.alipay.sofa.rpc.enable-hystrix=true


public String getAftRegulationEffective() {
return StringUtils.isEmpty(aftRegulationEffective) ? getDotString(new Object() {
}.getClass().getEnclosingMethod().getName()) : aftRegulationEffective;
@@ -544,6 +546,15 @@ public void setConsumerRepeatedReferenceLimit(String consumerRepeatedReferenceLi
this.consumerRepeatedReferenceLimit = consumerRepeatedReferenceLimit;
}

public String getEnableHystrix() {
return StringUtils.isEmpty(enableHystrix) ? getDotString(new Object() {
}.getClass().getEnclosingMethod().getName()) : enableHystrix;
}

public void setEnableHystrix(String enableHystrix) {
this.enableHystrix = enableHystrix;
}

private String getDotString(String enclosingMethodName) {
if (environment == null) {
return null;
Original file line number Diff line number Diff line change
@@ -174,8 +174,12 @@ public ConsumerConfig getConsumerConfig(Contract contract, RpcBinding binding) {
consumerConfig.setSerialization(serialization);
}

if (param.getParamters() != null) {
consumerConfig.setParameters(param.getParamters());
if (param.getParameters() != null) {
consumerConfig.setParameters(param.getParameters());
}

if (Boolean.TRUE.toString().equals(sofaBootRpcProperties.getEnableHystrix())) {
consumerConfig.setParameter(HystrixConstants.SOFA_HYSTRIX_ENABLED, true);
}

return consumerConfig.setProtocol(protocol);
Original file line number Diff line number Diff line change
@@ -131,8 +131,8 @@ public ProviderConfig getProviderConfig(Contract contract, RpcBinding binding, O
providerConfig.setSerialization(serialization);
}

if (param.getParamters() != null) {
providerConfig.setParameters(param.getParamters());
if (param.getParameters() != null) {
providerConfig.setParameters(param.getParameters());
}

if (param.getRegistrys() != null && param.getRegistrys().size() > 0) {
Original file line number Diff line number Diff line change
@@ -75,9 +75,9 @@ public abstract class RpcBindingParam implements BindingParam {

protected String serialization;

protected Map<String, String> paramters = new ConcurrentHashMap<String, String>();
protected Map<String, String> parameters = new ConcurrentHashMap<String, String>();

protected List<String> registrys = new ArrayList<String>();
protected List<String> registrys = new ArrayList<String>();

/**
* Getter method for property <tt>timeout</tt>.
@@ -429,12 +429,12 @@ public void setSerialization(String serialization) {
this.serialization = serialization;
}

public Map<String, String> getParamters() {
return paramters;
public Map<String, String> getParameters() {
return parameters;
}

public void setParamters(Map<String, String> paramters) {
this.paramters = paramters;
public void setParameters(Map<String, String> parameters) {
this.parameters = parameters;
}

public List<String> getRegistrys() {
@@ -494,7 +494,7 @@ public boolean equals(Object o) {
return false;
if (serialization != null ? !serialization.equals(that.serialization) : that.serialization != null)
return false;
if (paramters != null ? !paramters.equals(that.paramters) : that.paramters != null)
if (parameters != null ? !parameters.equals(that.parameters) : that.parameters != null)
return false;
return registrys != null ? registrys.equals(that.registrys) : that.registrys == null;
}
@@ -521,7 +521,7 @@ public int hashCode() {
result = 31 * result + (methodInfos != null ? methodInfos.hashCode() : 0);
result = 31 * result + (targetUrl != null ? targetUrl.hashCode() : 0);
result = 31 * result + (serialization != null ? serialization.hashCode() : 0);
result = 31 * result + (paramters != null ? paramters.hashCode() : 0);
result = 31 * result + (parameters != null ? parameters.hashCode() : 0);
result = 31 * result + (registrys != null ? registrys.hashCode() : 0);
return result;
}