Java Code Examples for com.alipay.sofa.rpc.common.utils.StringUtils#split()
The following examples show how to use
com.alipay.sofa.rpc.common.utils.StringUtils#split() .
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: LocalRegistryHelper.java From sofa-rpc with Apache License 2.0 | 6 votes |
private static Map<String, ProviderGroup> unMarshal(String context) { if (StringUtils.isBlank(context)) { return null; } Map<String, ProviderGroup> map = new HashMap<String, ProviderGroup>(); String[] lines = StringUtils.split(context, FileUtils.LINE_SEPARATOR); for (String line : lines) { String[] fields = line.split(SEPARATORSTR); if (fields.length > 1) { String key = fields[0]; Set<ProviderInfo> values = new HashSet<ProviderInfo>(); for (int i = 1; i < fields.length; i++) { String pstr = fields[i]; if (StringUtils.isNotEmpty(pstr)) { ProviderInfo providerInfo = ProviderHelper.toProviderInfo(pstr); providerInfo.setStaticAttr(ProviderInfoAttrs.ATTR_SOURCE, "local"); values.add(providerInfo); } } map.put(key, new ProviderGroup(new ArrayList<ProviderInfo>(values))); } } return map; }
Example 2
Source File: SofaRegistrySubscribeCallback.java From sofa-rpc with Apache License 2.0 | 6 votes |
/** * merge data * * @param userData * @param configData * @return */ private ComposeUserData composeUserAndConfigData(UserData userData, ConfigData configData) { ComposeUserData result = new ComposeUserData(); Map<String, List<ProviderInfo>> zoneData = new HashMap<String, List<ProviderInfo>>(); if (userData == null) { return result; } else { result.setLocalZone(userData.getLocalZone()); final Map<String, List<String>> listZoneData = userData.getZoneData(); final String[] configDatas = StringUtils.split( configData == null ? StringUtils.EMPTY : configData.getData(), CONFIG_SEPARATOR); final List<String> attrData = Arrays.asList(configDatas); for (String key : listZoneData.keySet()) { final List<ProviderInfo> providerInfos = mergeProviderInfo(listZoneData.get(key), attrData); zoneData.put(key, providerInfos); } result.setZoneData(zoneData); } return result; }
Example 3
Source File: SofaRegistrySubscribeCallback.java From sofa-rpc with Apache License 2.0 | 6 votes |
/** * 获得 Sofa Runtime 的日志对象,打印出获得Config Data 信息 */ private void printConfigData(String dataId, ConfigData configData) { StringBuilder sb = new StringBuilder(); int count = 0; if (configData != null && StringUtils.isNotBlank(configData.getData())) { final String[] split = StringUtils.split(configData.getData(), CONFIG_SEPARATOR); List<String> dataList = Arrays.asList(split); for (String provider : dataList) { sb.append(" >>> ").append(provider).append("\n"); count++; } } if (LOGGER.isInfoEnabled()) { LOGGER.info(LogCodes.getLiteLog( "Receive RPC config info: service[{0}]\n usable config info[{1}]\n{2}", dataId, count, sb.toString())); } }