Java Code Examples for com.alipay.sofa.rpc.config.ProviderConfig#getTimeout()
The following examples show how to use
com.alipay.sofa.rpc.config.ProviderConfig#getTimeout() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DubboProviderBootstrap.java From sofa-rpc with Apache License 2.0 | 6 votes |
private void copyProvider(ProviderConfig<T> providerConfig, ServiceConfig<T> serviceConfig) { serviceConfig.setId(providerConfig.getId()); serviceConfig.setInterface(providerConfig.getInterfaceId()); serviceConfig.setRef(providerConfig.getRef()); serviceConfig.setGroup(providerConfig.getUniqueId()); serviceConfig.setVersion("1.0"); serviceConfig.setActives(providerConfig.getConcurrents()); serviceConfig.setDelay(providerConfig.getDelay()); serviceConfig.setDynamic(providerConfig.isDynamic()); serviceConfig.setRegister(providerConfig.isRegister()); serviceConfig.setProxy(providerConfig.getProxy()); serviceConfig.setWeight(providerConfig.getWeight()); if (providerConfig.getTimeout() > 0) { serviceConfig.setTimeout(providerConfig.getTimeout()); } serviceConfig.setParameters(providerConfig.getParameters()); }
Example 2
Source File: SofaRegistryHelper.java From sofa-rpc with Apache License 2.0 | 4 votes |
/** * Convert provider to url. * * @param providerConfig the ProviderConfig * @return the url list */ public static String convertProviderToUrls(ProviderConfig providerConfig, ServerConfig server) { StringBuilder sb = new StringBuilder(200); String appName = providerConfig.getAppName(); String host = server.getVirtualHost(); // 虚拟ip if (host == null) { host = server.getHost(); if (NetUtils.isLocalHost(host) || NetUtils.isAnyHost(host)) { host = SystemInfo.getLocalHost(); } } else { if (LOGGER.isWarnEnabled(appName)) { LOGGER.warnWithApp(appName, "Virtual host is specified, host will be change from {} to {} when register", server.getHost(), host); } } Integer port = server.getVirtualPort(); // 虚拟port if (port == null) { port = server.getPort(); } else { if (LOGGER.isWarnEnabled(appName)) { LOGGER.warnWithApp(appName, "Virtual port is specified, host will be change from {} to {} when register", server.getPort(), port); } } String protocol = server.getProtocol(); sb.append(host).append(":").append(port).append(server.getContextPath()); // .append(providerConfig.getInterfaceId()) sb.append("?").append(ATTR_RPC_VERSION).append("=").append(Version.RPC_VERSION); sb.append(getKeyPairs(ATTR_SERIALIZATION, providerConfig.getSerialization())); sb.append(getKeyPairs(ATTR_WEIGHT, providerConfig.getWeight())); if (providerConfig.getTimeout() > 0) { sb.append(getKeyPairs(ATTR_TIMEOUT, providerConfig.getTimeout())); } sb.append(getKeyPairs(ATTR_APP_NAME, appName)); // sb.append(getKeyPairs("delay", providerConfig.getDelay())) // .append(getKeyPairs("timeout", providerConfig.getTimeout())) // .append(getKeyPairs("delay", providerConfig.getDelay())) // .append(getKeyPairs("id", providerConfig.getId())) // .append(getKeyPairs("dynamic", providerConfig.isDynamic())) // .append(getKeyPairs("weight", providerConfig.getWeight())) // .append(getKeyPairs("crossLang", providerConfig.getParameter("crossLang"))) // .append(getKeyPairs("accepts", server.getAccepts())); // 兼容老系统,代码是否剥离? if (PROTOCOL_TYPE_BOLT.equals(protocol)) { sb.append(getKeyPairs(RPC_REMOTING_PROTOCOL, RemotingConstants.PROTOCOL_BOLT)); // p=1 } else if (PROTOCOL_TYPE_TR.equals(protocol)) { sb.append(getKeyPairs(RPC_REMOTING_PROTOCOL, RemotingConstants.PROTOCOL_TR));// p=13 } sb.append(getKeyPairs(RPC_SERVICE_VERSION, SOFA4_RPC_SERVICE_VERSION)); // v=4.0 sb.append(getKeyPairs(SERIALIZE_TYPE_KEY, providerConfig.getSerialization())); // _SERIALIZETYPE=xx sb.append(getKeyPairs(WEIGHT_KEY, providerConfig.getWeight())); // _WEIGHT=100 if (providerConfig.getTimeout() > 0) { sb.append(getKeyPairs(TIMEOUT, providerConfig.getTimeout())); // _TIMEOUT=3000 } sb.append(getKeyPairs(APP_NAME, appName)); // sb.append(getKeyPairs(SELF_APP_NAME, appName)); //TODO self_app_name // sb.append(getKeyPairs(IDLE_TIMEOUT, 27)); //TODO _IDLETIMEOUT // sb.append(getKeyPairs(MAX_READ_IDLE, 30)); //TODO _MAXREADIDLETIME if (StringUtils.isNotBlank(SystemInfo.getHostMachine())) { sb.append(getKeyPairs(HOST_MACHINE_KEY, SystemInfo.getHostMachine())); } Map<String, MethodConfig> methodConfigs = providerConfig.getMethods(); if (CommonUtils.isNotEmpty(methodConfigs)) { for (Map.Entry<String, MethodConfig> entry : methodConfigs.entrySet()) { String methodName = entry.getKey(); MethodConfig methodConfig = entry.getValue(); sb.append(getKeyPairs("." + methodName + "." + ATTR_TIMEOUT, methodConfig.getTimeout())); // 方法级配置,只能放timeout String key = "[" + methodName + "]"; String value = "[" + KEY_TIMEOUT + "#" + methodConfig.getTimeout() + "]"; sb.append(getKeyPairs(key, value)); } } sb.append(convertMap2Pair(providerConfig.getParameters())); addCommonAttrs(sb); return sb.toString(); }
Example 3
Source File: SofaRegistryHelper.java From sofa-rpc with Apache License 2.0 | 4 votes |
/** * Convert provider to url. * * @param providerConfig the ProviderConfig * @return the url list */ public static String convertProviderToUrls(ProviderConfig providerConfig, ServerConfig server) { StringBuilder sb = new StringBuilder(200); String appName = providerConfig.getAppName(); String host = server.getVirtualHost(); // 虚拟ip if (host == null) { host = server.getHost(); if (NetUtils.isLocalHost(host) || NetUtils.isAnyHost(host)) { host = SystemInfo.getLocalHost(); } } else { if (LOGGER.isWarnEnabled(appName)) { LOGGER.warnWithApp(appName, "Virtual host is specified, host will be change from {} to {} when register", server.getHost(), host); } } Integer port = server.getVirtualPort(); // 虚拟port if (port == null) { port = server.getPort(); } else { if (LOGGER.isWarnEnabled(appName)) { LOGGER.warnWithApp(appName, "Virtual port is specified, host will be change from {} to {} when register", server.getPort(), port); } } String protocol = server.getProtocol(); sb.append(host).append(":").append(port).append(server.getContextPath()); // .append(providerConfig.getInterfaceId()) sb.append("?").append(ATTR_RPC_VERSION).append("=").append(Version.RPC_VERSION); sb.append(getKeyPairs(ATTR_SERIALIZATION, providerConfig.getSerialization())); sb.append(getKeyPairs(ATTR_WEIGHT, providerConfig.getWeight())); if (providerConfig.getTimeout() > 0) { sb.append(getKeyPairs(ATTR_TIMEOUT, providerConfig.getTimeout())); } sb.append(getKeyPairs(ATTR_APP_NAME, appName)); // sb.append(getKeyPairs("delay", providerConfig.getDelay())) // .append(getKeyPairs("timeout", providerConfig.getTimeout())) // .append(getKeyPairs("delay", providerConfig.getDelay())) // .append(getKeyPairs("id", providerConfig.getId())) // .append(getKeyPairs("dynamic", providerConfig.isDynamic())) // .append(getKeyPairs("weight", providerConfig.getWeight())) // .append(getKeyPairs("crossLang", providerConfig.getParameter("crossLang"))) // .append(getKeyPairs("accepts", server.getAccepts())); // 兼容老系统,代码是否剥离? if (PROTOCOL_TYPE_BOLT.equals(protocol)) { sb.append(getKeyPairs(RPC_REMOTING_PROTOCOL, RemotingConstants.PROTOCOL_BOLT)); // p=1 } else if (PROTOCOL_TYPE_TR.equals(protocol)) { sb.append(getKeyPairs(RPC_REMOTING_PROTOCOL, RemotingConstants.PROTOCOL_TR));// p=13 } sb.append(getKeyPairs(RPC_SERVICE_VERSION, SOFA4_RPC_SERVICE_VERSION)); // v=4.0 sb.append(getKeyPairs(SERIALIZE_TYPE_KEY, providerConfig.getSerialization())); // _SERIALIZETYPE=xx sb.append(getKeyPairs(WEIGHT_KEY, providerConfig.getWeight())); // _WEIGHT=100 if (providerConfig.getTimeout() > 0) { sb.append(getKeyPairs(TIMEOUT, providerConfig.getTimeout())); // _TIMEOUT=3000 } sb.append(getKeyPairs(APP_NAME, appName)); // sb.append(getKeyPairs(SELF_APP_NAME, appName)); //TODO self_app_name // sb.append(getKeyPairs(IDLE_TIMEOUT, 27)); //TODO _IDLETIMEOUT // sb.append(getKeyPairs(MAX_READ_IDLE, 30)); //TODO _MAXREADIDLETIME if (StringUtils.isNotBlank(SystemInfo.getHostMachine())) { sb.append(getKeyPairs(HOST_MACHINE_KEY, SystemInfo.getHostMachine())); } Map<String, MethodConfig> methodConfigs = providerConfig.getMethods(); if (CommonUtils.isNotEmpty(methodConfigs)) { for (Map.Entry<String, MethodConfig> entry : methodConfigs.entrySet()) { String methodName = entry.getKey(); MethodConfig methodConfig = entry.getValue(); sb.append(getKeyPairs("." + methodName + "." + ATTR_TIMEOUT, methodConfig.getTimeout())); // 方法级配置,只能放timeout String key = "[" + methodName + "]"; String value = "[" + KEY_TIMEOUT + "#" + methodConfig.getTimeout() + "]"; sb.append(getKeyPairs(key, value)); } } sb.append(convertMap2Pair(providerConfig.getParameters())); addCommonAttrs(sb); return sb.toString(); }
Example 4
Source File: MockTestRegistry.java From sofa-rpc with Apache License 2.0 | 4 votes |
/** * Convert provider to url. * * @param providerConfig the ProviderConfig * @return the url list */ public static String convertProviderToUrls(ProviderConfig providerConfig, ServerConfig server) { StringBuilder sb = new StringBuilder(200); String appName = providerConfig.getAppName(); String host = server.getVirtualHost(); // 虚拟ip if (host == null) { host = server.getHost(); if (NetUtils.isLocalHost(host) || NetUtils.isAnyHost(host)) { host = SystemInfo.getLocalHost(); } } else { if (LOGGER.isWarnEnabled(appName)) { LOGGER.warnWithApp(appName, "Virtual host is specified, host will be change from {} to {} when register", server.getHost(), host); } } Integer port = server.getVirtualPort(); // 虚拟port if (port == null) { port = server.getPort(); } else { if (LOGGER.isWarnEnabled(appName)) { LOGGER.warnWithApp(appName, "Virtual port is specified, host will be change from {} to {} when register", server.getPort(), port); } } String protocol = server.getProtocol(); sb.append(host).append(":").append(port).append(server.getContextPath()); sb.append("?").append(ATTR_RPC_VERSION).append("=").append(Version.RPC_VERSION); sb.append(getKeyPairs(ATTR_SERIALIZATION, providerConfig.getSerialization())); sb.append(getKeyPairs(ATTR_WEIGHT, providerConfig.getWeight())); if (providerConfig.getTimeout() > 0) { sb.append(getKeyPairs(ATTR_TIMEOUT, providerConfig.getTimeout())); } sb.append(getKeyPairs(ATTR_APP_NAME, appName)); sb.append(getKeyPairs(ATTR_WARMUP_TIME, providerConfig.getParameter(ATTR_WARMUP_TIME.toString()))); sb.append(getKeyPairs(ATTR_WARMUP_WEIGHT, providerConfig.getParameter(ATTR_WARMUP_WEIGHT.toString()))); Map<String, MethodConfig> methodConfigs = providerConfig.getMethods(); if (CommonUtils.isNotEmpty(methodConfigs)) { for (Map.Entry<String, MethodConfig> entry : methodConfigs.entrySet()) { String methodName = entry.getKey(); MethodConfig methodConfig = entry.getValue(); sb.append(getKeyPairs("." + methodName + "." + ATTR_TIMEOUT, methodConfig.getTimeout())); // 方法级配置,只能放timeout String key = "[" + methodName + "]"; String value = "[clientTimeout" + "#" + methodConfig.getTimeout() + "]"; sb.append(getKeyPairs(key, value)); } } sb.append(getKeyPairs(ATTR_START_TIME, RpcRuntimeContext.now())); return sb.toString(); }