ClusterAgent优化

This commit is contained in:
redkale
2023-11-16 13:16:42 +08:00
parent e44afc9208
commit b256db65d4
3 changed files with 12 additions and 4 deletions

View File

@@ -213,7 +213,7 @@ public abstract class ClusterAgent {
try {
Thread.sleep(s * 1000);
} catch (InterruptedException ex) {
//do nothing
//do nothing
}
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) {
return protocol.toLowerCase() + ":" + restype + (resname == null || resname.isEmpty() ? "" : ("-" + resname));
return protocol.toLowerCase() + ":" + restype + (Utility.isEmpty(resname) ? "" : ("-" + resname));
}
//也会提供给HttpMessageClusterAgent适用
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

View File

@@ -83,7 +83,7 @@ public class HttpClusterRpcClient extends HttpRpcClient {
module = module.substring(1); //去掉/
module = module.substring(0, module.indexOf('/'));
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;
if (logger.isLoggable(Level.FINEST)) {
logger.log(Level.FINEST, "httpAsync.queryHttpAddress: module=" + localModule + ", resname=" + resname);

View File

@@ -351,6 +351,14 @@ public class HttpSimpleRequest extends ClientRequest implements java.io.Serializ
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() {
return rpc;
}