ClusterAgent优化
This commit is contained in:
@@ -213,7 +213,7 @@ public abstract class ClusterAgent {
|
|||||||
try {
|
try {
|
||||||
Thread.sleep(s * 1000);
|
Thread.sleep(s * 1000);
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
//do nothing
|
//do nothing
|
||||||
}
|
}
|
||||||
logger.info(this.getClass().getSimpleName() + " wait for " + s * 1000 + "ms after deregister");
|
logger.info(this.getClass().getSimpleName() + " wait for " + s * 1000 + "ms after deregister");
|
||||||
}
|
}
|
||||||
@@ -285,12 +285,12 @@ public abstract class ClusterAgent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String generateSncpServiceName(String protocol, String restype, String resname) {
|
public String generateSncpServiceName(String protocol, String restype, String resname) {
|
||||||
return protocol.toLowerCase() + ":" + restype + (resname == null || resname.isEmpty() ? "" : ("-" + resname));
|
return protocol.toLowerCase() + ":" + restype + (Utility.isEmpty(resname) ? "" : ("-" + resname));
|
||||||
}
|
}
|
||||||
|
|
||||||
//也会提供给HttpMessageClusterAgent适用
|
//也会提供给HttpMessageClusterAgent适用
|
||||||
public String generateHttpServiceName(String protocol, String module, String resname) {
|
public String generateHttpServiceName(String protocol, String module, String resname) {
|
||||||
return protocol.toLowerCase() + ":" + module + (resname == null || resname.isEmpty() ? "" : ("-" + resname));
|
return protocol.toLowerCase() + ":" + module + (Utility.isEmpty(resname) ? "" : ("-" + resname));
|
||||||
}
|
}
|
||||||
|
|
||||||
//格式: protocol:classtype-resourcename
|
//格式: protocol:classtype-resourcename
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ public class HttpClusterRpcClient extends HttpRpcClient {
|
|||||||
module = module.substring(1); //去掉/
|
module = module.substring(1); //去掉/
|
||||||
module = module.substring(0, module.indexOf('/'));
|
module = module.substring(0, module.indexOf('/'));
|
||||||
Map<String, String> headers = req.getHeaders();
|
Map<String, String> headers = req.getHeaders();
|
||||||
String resname = headers == null ? "" : headers.getOrDefault(Rest.REST_HEADER_RESNAME, "");
|
String resname = req.getHeader(Rest.REST_HEADER_RESNAME, "");
|
||||||
final String localModule = module;
|
final String localModule = module;
|
||||||
if (logger.isLoggable(Level.FINEST)) {
|
if (logger.isLoggable(Level.FINEST)) {
|
||||||
logger.log(Level.FINEST, "httpAsync.queryHttpAddress: module=" + localModule + ", resname=" + resname);
|
logger.log(Level.FINEST, "httpAsync.queryHttpAddress: module=" + localModule + ", resname=" + resname);
|
||||||
|
|||||||
@@ -351,6 +351,14 @@ public class HttpSimpleRequest extends ClientRequest implements java.io.Serializ
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getHeader(String name) {
|
||||||
|
return headers == null ? null : headers.get(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHeader(String name, String defaultValue) {
|
||||||
|
return headers == null ? defaultValue : headers.getOrDefault(name, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isRpc() {
|
public boolean isRpc() {
|
||||||
return rpc;
|
return rpc;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user