Skip to content

Commit

Permalink
Merge pull request #2816 from alibaba/develop
Browse files Browse the repository at this point in the history
merge 1.3.0 Beta
  • Loading branch information
yanlinly authored May 15, 2020
2 parents fe923ab + b10745b commit 2cf0d40
Show file tree
Hide file tree
Showing 425 changed files with 32,982 additions and 9,855 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ target
.DS_Store
.factorypath
/logs
/lib
*.iml
node_modules
test/derby.log
derby.log
work
test/logs
derby.log
2 changes: 1 addition & 1 deletion address/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<parent>
<artifactId>nacos-all</artifactId>
<groupId>com.alibaba.nacos</groupId>
<version>1.2.1</version>
<version>1.3.0-BETA</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<parent>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-all</artifactId>
<version>1.2.1</version>
<version>1.3.0-BETA</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
240 changes: 120 additions & 120 deletions api/src/main/java/com/alibaba/nacos/api/exception/NacosException.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,125 +25,125 @@
*/
public class NacosException extends Exception {

/**
* serialVersionUID
*/
private static final long serialVersionUID = -3913902031489277776L;

private int errCode;

private String errMsg;

private Throwable causeThrowable;

public NacosException() {
}

public NacosException(int errCode, String errMsg) {
super(errMsg);
this.errCode = errCode;
this.errMsg = errMsg;
}

public NacosException(int errCode, Throwable throwable) {
super(throwable);
this.errCode = errCode;
setCauseThrowable(throwable);
}

public NacosException(int errCode, String errMsg, Throwable throwable) {
super(errMsg, throwable);
this.errCode = errCode;
this.errMsg = errMsg;
setCauseThrowable(throwable);
}

public int getErrCode() {
return errCode;
}

public String getErrMsg() {
if (!StringUtils.isBlank(this.errMsg)) {
return errMsg;
}
if (this.causeThrowable != null) {
return causeThrowable.getMessage();
}
return Constants.NULL;
}

public void setErrCode(int errCode) {
this.errCode = errCode;
}

public void setErrMsg(String errMsg) {
this.errMsg = errMsg;
}

public void setCauseThrowable(Throwable throwable) {
this.causeThrowable = getCauseThrowable(throwable);
}

private Throwable getCauseThrowable(Throwable t) {
if (t.getCause() == null) {
return t;
}
return getCauseThrowable(t.getCause());
}

@Override
public String toString() {
return "ErrCode:" + getErrCode() + ", ErrMsg:" + getErrMsg();
}

/**
* client error code
* -400 -503 throw exception to user
*/
/**
* invalid param(参数错误)
*/
public static final int CLIENT_INVALID_PARAM = -400;
/**
* over client threshold(超过server端的限流阈值)
*/
public static final int CLIENT_OVER_THRESHOLD = -503;

/**
* server error code
* 400 403 throw exception to user
* 500 502 503 change ip and retry
*/

/**
* invalid param(参数错误)
*/
public static final int INVALID_PARAM = 400;
/**
* no right(鉴权失败)
*/
public static final int NO_RIGHT = 403;
/**
* not found
*/
public static final int NOT_FOUND = 404;
/**
* conflict(写并发冲突)
*/
public static final int CONFLICT = 409;
/**
* server error(server异常,如超时)
*/
public static final int SERVER_ERROR = 500;
/**
* bad gateway(路由异常,如nginx后面的Server挂掉)
*/
public static final int BAD_GATEWAY = 502;
/**
* over threshold(超过server端的限流阈值)
*/
public static final int OVER_THRESHOLD = 503;

public static final int RESOURCE_NOT_FOUND = -404;
/**
* serialVersionUID
*/
private static final long serialVersionUID = -3913902031489277776L;

private int errCode;

private String errMsg;

private Throwable causeThrowable;

public NacosException() {
}

public NacosException(int errCode, String errMsg) {
super(errMsg);
this.errCode = errCode;
this.errMsg = errMsg;
}

public NacosException(int errCode, Throwable throwable) {
super(throwable);
this.errCode = errCode;
setCauseThrowable(throwable);
}

public NacosException(int errCode, String errMsg, Throwable throwable) {
super(errMsg, throwable);
this.errCode = errCode;
this.errMsg = errMsg;
setCauseThrowable(throwable);
}

public int getErrCode() {
return errCode;
}

public String getErrMsg() {
if (!StringUtils.isBlank(this.errMsg)) {
return errMsg;
}
if (this.causeThrowable != null) {
return causeThrowable.getMessage();
}
return Constants.NULL;
}

public void setErrCode(int errCode) {
this.errCode = errCode;
}

public void setErrMsg(String errMsg) {
this.errMsg = errMsg;
}

public void setCauseThrowable(Throwable throwable) {
this.causeThrowable = getCauseThrowable(throwable);
}

private Throwable getCauseThrowable(Throwable t) {
if (t.getCause() == null) {
return t;
}
return getCauseThrowable(t.getCause());
}

@Override
public String toString() {
return "ErrCode:" + getErrCode() + ", ErrMsg:" + getErrMsg();
}

/**
* client error code
* -400 -503 throw exception to user
*/
/**
* invalid param(参数错误)
*/
public static final int CLIENT_INVALID_PARAM = -400;
/**
* over client threshold(超过server端的限流阈值)
*/
public static final int CLIENT_OVER_THRESHOLD = -503;

/**
* server error code
* 400 403 throw exception to user
* 500 502 503 change ip and retry
*/

/**
* invalid param(参数错误)
*/
public static final int INVALID_PARAM = 400;
/**
* no right(鉴权失败)
*/
public static final int NO_RIGHT = 403;
/**
* not found
*/
public static final int NOT_FOUND = 404;
/**
* conflict(写并发冲突)
*/
public static final int CONFLICT = 409;
/**
* server error(server异常,如超时)
*/
public static final int SERVER_ERROR = 500;
/**
* bad gateway(路由异常,如nginx后面的Server挂掉)
*/
public static final int BAD_GATEWAY = 502;
/**
* over threshold(超过server端的限流阈值)
*/
public static final int OVER_THRESHOLD = 503;

public static final int RESOURCE_NOT_FOUND = -404;

}
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,7 @@ public boolean equals(Object obj) {
}

Instance host = (Instance) obj;

return strEquals(toString(), host.toString());
return strEquals(host.toString(), toString());
}

@Override
Expand Down
6 changes: 3 additions & 3 deletions client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<parent>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-all</artifactId>
<version>1.2.1</version>
<version>1.3.0-BETA</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -129,8 +129,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>6</source>
<target>6</target>
<source>7</source>
<target>7</target>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.alibaba.nacos.client.config.utils.ParamUtils;
import com.alibaba.nacos.client.utils.LogUtils;
import com.alibaba.nacos.client.utils.ParamUtil;
import com.alibaba.nacos.client.utils.ValidatorUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;

Expand Down Expand Up @@ -70,6 +71,7 @@ public class NacosConfigService implements ConfigService {
private ConfigFilterChainManager configFilterChainManager = new ConfigFilterChainManager();

public NacosConfigService(Properties properties) throws NacosException {
ValidatorUtils.checkInitParam(properties);
String encodeTmp = properties.getProperty(PropertyKeyConst.ENCODE);
if (StringUtils.isBlank(encodeTmp)) {
encode = Constants.ENCODE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,10 @@ public HttpResult httpDelete(String path, List<String> headers, List<String> par
return result;
}
} catch (ConnectException ce) {
ce.printStackTrace();
LOGGER.error("[NACOS ConnectException httpDelete] currentServerAddr:{}, err : {}", serverListMgr.getCurrentServerAddr(), ce.getMessage());
} catch (SocketTimeoutException stoe) {
stoe.printStackTrace();
LOGGER.error("[NACOS SocketTimeoutException httpDelete] currentServerAddr:{}, err : {}", serverListMgr.getCurrentServerAddr(), stoe.getMessage());
} catch (IOException ioe) {
LOGGER.error("[NACOS IOException httpDelete] currentServerAddr: " + serverListMgr.getCurrentServerAddr(), ioe);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import com.alibaba.nacos.client.config.filter.impl.ConfigFilterChainManager;
import com.alibaba.nacos.client.config.filter.impl.ConfigResponse;
import com.alibaba.nacos.client.config.listener.impl.AbstractConfigChangeListener;
import com.alibaba.nacos.client.config.utils.MD5;
import com.alibaba.nacos.common.utils.MD5Utils;
import com.alibaba.nacos.client.utils.LogUtils;
import com.alibaba.nacos.client.utils.TenantUtil;
import org.slf4j.Logger;
Expand Down Expand Up @@ -242,7 +242,7 @@ public void run() {
}

static public String getMd5String(String config) {
return (null == config) ? Constants.NULL : MD5.getInstance().getMD5String(config);
return (null == config) ? Constants.NULL : MD5Utils.md5Hex(config, Constants.ENCODE);
}

private String loadCacheContentFromDiskLocal(String name, String dataId, String group, String tenant) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import com.alibaba.nacos.client.config.http.HttpAgent;
import com.alibaba.nacos.client.config.impl.HttpSimpleClient.HttpResult;
import com.alibaba.nacos.client.config.utils.ContentUtils;
import com.alibaba.nacos.client.config.utils.MD5;
import com.alibaba.nacos.common.utils.MD5Utils;
import com.alibaba.nacos.client.monitor.MetricsMonitor;
import com.alibaba.nacos.client.utils.LogUtils;
import com.alibaba.nacos.client.utils.ParamUtil;
Expand Down Expand Up @@ -279,7 +279,7 @@ private void checkLocalConfig(CacheData cacheData) {
// 没有 -> 有
if (!cacheData.isUseLocalConfigInfo() && path.exists()) {
String content = LocalConfigInfoProcessor.getFailover(agent.getName(), dataId, group, tenant);
String md5 = MD5.getInstance().getMD5String(content);
String md5 = MD5Utils.md5Hex(content, Constants.ENCODE);
cacheData.setUseLocalConfigInfo(true);
cacheData.setLocalConfigInfoVersion(path.lastModified());
cacheData.setContent(content);
Expand All @@ -301,7 +301,7 @@ private void checkLocalConfig(CacheData cacheData) {
if (cacheData.isUseLocalConfigInfo() && path.exists()
&& cacheData.getLocalConfigInfoVersion() != path.lastModified()) {
String content = LocalConfigInfoProcessor.getFailover(agent.getName(), dataId, group, tenant);
String md5 = MD5.getInstance().getMD5String(content);
String md5 = MD5Utils.md5Hex(content, Constants.ENCODE);
cacheData.setUseLocalConfigInfo(true);
cacheData.setLocalConfigInfoVersion(path.lastModified());
cacheData.setContent(content);
Expand Down
Loading

0 comments on commit 2cf0d40

Please sign in to comment.