From aa1d36a7dfcf0dbb09a7cea699382a3013cb0b39 Mon Sep 17 00:00:00 2001 From: dzdx Date: Tue, 15 Dec 2020 11:41:11 +0800 Subject: [PATCH] [app-discovery] filter databox by revision --- .../core/model/AppRevisionInterface.java | 80 +++++++++++++++++-- .../core/model/AppRevisionRegister.java | 80 ++++++++++++++++++- .../model/AppRegisterServerDataBox.java | 36 +++------ .../common/model/PublisherInternUtil.java | 3 +- .../service/RaftAppRevisionService.java | 3 +- .../meta/revision/AppRevisionRegistry.java | 2 +- .../assemble/AppInterfaceAssembleService.java | 10 +-- .../cache/AppRevisionCacheRegistry.java | 22 ++--- .../cache/SessionDatumCacheDecorator.java | 3 +- .../converter/AppPublisherConverter.java | 59 ++++++++------ .../session/converter/PublisherConverter.java | 9 +-- .../session/predicate/RevisionPredicate.java | 2 +- .../session/registry/SessionRegistry.java | 5 +- .../store/AppPublisherConverterTest.java | 10 ++- 14 files changed, 228 insertions(+), 96 deletions(-) diff --git a/core/src/main/java/com/alipay/sofa/registry/core/model/AppRevisionInterface.java b/core/src/main/java/com/alipay/sofa/registry/core/model/AppRevisionInterface.java index 8524f6afc..a0152d0fc 100644 --- a/core/src/main/java/com/alipay/sofa/registry/core/model/AppRevisionInterface.java +++ b/core/src/main/java/com/alipay/sofa/registry/core/model/AppRevisionInterface.java @@ -22,12 +22,80 @@ import java.util.Map; public class AppRevisionInterface implements Serializable { - public String dataId; - public String group; - public String instanceId; - public Map> serviceParams; + private String dataId; + private String group; + private String instanceId; + private Map> serviceParams = new HashMap<>(); - public AppRevisionInterface() { - serviceParams = new HashMap<>(); + /** + * Getter method for property dataId. + * + * @return property value of dataId + */ + public String getDataId() { + return dataId; + } + + /** + * Setter method for property dataId. + * + * @param dataId value to be assigned to property dataId + */ + public void setDataId(String dataId) { + this.dataId = dataId; + } + + /** + * Getter method for property group. + * + * @return property value of group + */ + public String getGroup() { + return group; + } + + /** + * Setter method for property group. + * + * @param group value to be assigned to property group + */ + public void setGroup(String group) { + this.group = group; + } + + /** + * Getter method for property instanceId. + * + * @return property value of instanceId + */ + public String getInstanceId() { + return instanceId; + } + + /** + * Setter method for property instanceId. + * + * @param instanceId value to be assigned to property instanceId + */ + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + /** + * Getter method for property serviceParams. + * + * @return property value of serviceParams + */ + public Map> getServiceParams() { + return serviceParams; + } + + /** + * Setter method for property serviceParams. + * + * @param serviceParams value to be assigned to property serviceParams + */ + public void setServiceParams(Map> serviceParams) { + this.serviceParams = serviceParams; } } diff --git a/core/src/main/java/com/alipay/sofa/registry/core/model/AppRevisionRegister.java b/core/src/main/java/com/alipay/sofa/registry/core/model/AppRevisionRegister.java index ddbef71c2..c9b5b516a 100644 --- a/core/src/main/java/com/alipay/sofa/registry/core/model/AppRevisionRegister.java +++ b/core/src/main/java/com/alipay/sofa/registry/core/model/AppRevisionRegister.java @@ -21,8 +21,80 @@ import java.util.Map; public class AppRevisionRegister implements Serializable { - public String revision; - public String appname; - public Map> baseParams; - public Map interfaces; + private String revision; + private String appName; + private Map> baseParams; + private Map interfaces; + + /** + * Getter method for property revision. + * + * @return property value of revision + */ + public String getRevision() { + return revision; + } + + /** + * Setter method for property revision. + * + * @param revision value to be assigned to property revision + */ + public void setRevision(String revision) { + this.revision = revision; + } + + /** + * Getter method for property appName. + * + * @return property value of appName + */ + public String getAppName() { + return appName; + } + + /** + * Setter method for property appName. + * + * @param appName value to be assigned to property appName + */ + public void setAppName(String appName) { + this.appName = appName; + } + + /** + * Getter method for property baseParams. + * + * @return property value of baseParams + */ + public Map> getBaseParams() { + return baseParams; + } + + /** + * Setter method for property baseParams. + * + * @param baseParams value to be assigned to property baseParams + */ + public void setBaseParams(Map> baseParams) { + this.baseParams = baseParams; + } + + /** + * Getter method for property interfaces. + * + * @return property value of interfaces + */ + public Map getInterfaces() { + return interfaces; + } + + /** + * Setter method for property interfaces. + * + * @param interfaces value to be assigned to property interfaces + */ + public void setInterfaces(Map interfaces) { + this.interfaces = interfaces; + } } diff --git a/server/common/model/src/main/java/com/alipay/sofa/registry/common/model/AppRegisterServerDataBox.java b/server/common/model/src/main/java/com/alipay/sofa/registry/common/model/AppRegisterServerDataBox.java index 58efe598d..08e7c5bf8 100644 --- a/server/common/model/src/main/java/com/alipay/sofa/registry/common/model/AppRegisterServerDataBox.java +++ b/server/common/model/src/main/java/com/alipay/sofa/registry/common/model/AppRegisterServerDataBox.java @@ -17,7 +17,6 @@ package com.alipay.sofa.registry.common.model; import com.alipay.sofa.registry.common.model.store.WordCache; -import com.google.common.collect.ArrayListMultimap; import java.io.Serializable; import java.util.HashMap; @@ -42,24 +41,7 @@ public class AppRegisterServerDataBox implements Serializable { private HashMap/*values*/> baseParams; /** */ - private Map/*value*/>> serviceParams; - - public String extract(String serviceName) { - serviceParams.get(serviceName); - - StringBuilder builder = new StringBuilder(); - builder.append("?"); - baseParams.entrySet().stream().forEach(entry -> { - entry.getValue().forEach(value -> builder.append(entry.getKey()).append("=").append(value).append("&")); - }); - - serviceParams.get(serviceName).entrySet().forEach(entry -> { - entry.getValue().forEach(value -> builder.append(entry.getKey()).append("=").append(value).append("&")); - }); - - - return builder.deleteCharAt(builder.toString().length() - 1).toString(); - } + private Map/*value*/>> interfaceParams; /** * Getter method for property revision. @@ -116,20 +98,20 @@ public void setBaseParams(HashMap> baseParams) { } /** - * Getter method for property serviceParams. + * Getter method for property interfaceParams. * - * @return property value of serviceParams + * @return property value of interfaceParams */ - public Map>> getServiceParams() { - return serviceParams; + public Map>> getInterfaceParams() { + return interfaceParams; } /** - * Setter method for property serviceParams. + * Setter method for property interfaceParams. * - * @param serviceParams value to be assigned to property serviceParams + * @param interfaceParams value to be assigned to property interfaceParams */ - public void setServiceParams(Map>> serviceParams) { - this.serviceParams = serviceParams; + public void setInterfaceParams(Map>> interfaceParams) { + this.interfaceParams = interfaceParams; } } \ No newline at end of file diff --git a/server/common/model/src/main/java/com/alipay/sofa/registry/common/model/PublisherInternUtil.java b/server/common/model/src/main/java/com/alipay/sofa/registry/common/model/PublisherInternUtil.java index 71e0dde67..bdc454e9f 100644 --- a/server/common/model/src/main/java/com/alipay/sofa/registry/common/model/PublisherInternUtil.java +++ b/server/common/model/src/main/java/com/alipay/sofa/registry/common/model/PublisherInternUtil.java @@ -24,7 +24,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Map.Entry; /** * @@ -66,7 +65,7 @@ public static Publisher internPublisher(Publisher publisher) { }); Map>> serviceParams = new HashMap<>(); - dataBox.getServiceParams().entrySet().forEach(entry -> { + dataBox.getInterfaceParams().entrySet().forEach(entry -> { // cache serviceName serviceParams.put(WordCache.getInstance().getWordCache(entry.getKey()), entry.getValue()); diff --git a/server/server/meta/src/main/java/com/alipay/sofa/registry/server/meta/repository/service/RaftAppRevisionService.java b/server/server/meta/src/main/java/com/alipay/sofa/registry/server/meta/repository/service/RaftAppRevisionService.java index ccc696b0b..de1358cf5 100644 --- a/server/server/meta/src/main/java/com/alipay/sofa/registry/server/meta/repository/service/RaftAppRevisionService.java +++ b/server/server/meta/src/main/java/com/alipay/sofa/registry/server/meta/repository/service/RaftAppRevisionService.java @@ -74,7 +74,6 @@ public boolean load(String path) { return true; } catch (IOException e) { LOGGER.error("Load app revisions error:", e); - e.printStackTrace(); return false; } } @@ -95,7 +94,7 @@ public Set getSnapshotFileNames() { public void add(AppRevisionRegister appRevision) { rwLock.writeLock().lock(); - if (registry.putIfAbsent(appRevision.revision, appRevision) == null) { + if (registry.putIfAbsent(appRevision.getRevision(), appRevision) == null) { keysDigest = generateKeysDigest(); } rwLock.writeLock().unlock(); diff --git a/server/server/meta/src/main/java/com/alipay/sofa/registry/server/meta/revision/AppRevisionRegistry.java b/server/server/meta/src/main/java/com/alipay/sofa/registry/server/meta/revision/AppRevisionRegistry.java index e62702900..96751c3cb 100644 --- a/server/server/meta/src/main/java/com/alipay/sofa/registry/server/meta/revision/AppRevisionRegistry.java +++ b/server/server/meta/src/main/java/com/alipay/sofa/registry/server/meta/revision/AppRevisionRegistry.java @@ -26,7 +26,7 @@ public class AppRevisionRegistry { private AppRevisionService appRevisionService; public void register(AppRevisionRegister appRevision) { - if (appRevisionService.existed(appRevision.revision)) { + if (appRevisionService.existed(appRevision.getRevision())) { return; } appRevisionService.add(appRevision); diff --git a/server/server/session/src/main/java/com/alipay/sofa/registry/server/session/assemble/AppInterfaceAssembleService.java b/server/server/session/src/main/java/com/alipay/sofa/registry/server/session/assemble/AppInterfaceAssembleService.java index 625c9a16d..f2eb8f723 100644 --- a/server/server/session/src/main/java/com/alipay/sofa/registry/server/session/assemble/AppInterfaceAssembleService.java +++ b/server/server/session/src/main/java/com/alipay/sofa/registry/server/session/assemble/AppInterfaceAssembleService.java @@ -126,11 +126,11 @@ private Datum doMerge(Datum interfaceDatum, Map appDatum, Subscri continue; } AppPublisher appPublisher = (AppPublisher) publisher; - - datum.getPubMap().put( - appPublisher.getRegisterId(), - AppPublisherConverter.convert(appPublisher, appRevisionCacheRegistry, - dataInfo)); + Publisher newPublisher = AppPublisherConverter.convert(appPublisher, + appRevisionCacheRegistry, dataInfo); + if (newPublisher.getDataList().size() > 0) { + datum.getPubMap().put(appPublisher.getRegisterId(), newPublisher); + } } } } diff --git a/server/server/session/src/main/java/com/alipay/sofa/registry/server/session/cache/AppRevisionCacheRegistry.java b/server/server/session/src/main/java/com/alipay/sofa/registry/server/session/cache/AppRevisionCacheRegistry.java index e7ef32993..e3afa0132 100644 --- a/server/server/session/src/main/java/com/alipay/sofa/registry/server/session/cache/AppRevisionCacheRegistry.java +++ b/server/server/session/src/main/java/com/alipay/sofa/registry/server/session/cache/AppRevisionCacheRegistry.java @@ -49,20 +49,20 @@ public AppRevisionCacheRegistry() { } public void register(AppRevisionRegister appRevision) throws Exception { - if (this.registry.containsKey(appRevision.revision)) { + if (this.registry.containsKey(appRevision.getRevision())) { return; } - singleFlight.execute("revisionRegister" + appRevision.revision, () -> { + singleFlight.execute("revisionRegister" + appRevision.getRevision(), () -> { appRevisionNodeService.register(appRevision); return null; }); } - public Set getApps(String dataInfoId) { + public Map> getAppRevisions(String dataInfoId) { if (!interfaceRevisions.containsKey(dataInfoId)) { - return new HashSet<>(); + return new HashMap<>(); } - return interfaceRevisions.get(dataInfoId).keySet(); + return interfaceRevisions.get(dataInfoId); } public AppRevisionRegister getRevision(String revision) { @@ -98,18 +98,18 @@ public void refreshAll() { } private void onNewRevision(AppRevisionRegister rev) { - for (AppRevisionInterface inf : rev.interfaces.values()) { - String dataInfoId = DataInfo.toDataInfoId(inf.dataId, inf.instanceId, inf.group); + for (AppRevisionInterface inf : rev.getInterfaces().values()) { + String dataInfoId = DataInfo.toDataInfoId(inf.getDataId(), inf.getInstanceId(), inf.getGroup()); Map> apps = interfaceRevisions.computeIfAbsent(dataInfoId, k -> new ConcurrentHashMap<>()); - Set infRevisions = apps.computeIfAbsent(rev.appname, + Set infRevisions = apps.computeIfAbsent(rev.getAppName(), k -> Sets.newConcurrentHashSet()); - infRevisions.add(rev.revision); + infRevisions.add(rev.getRevision()); - appInterfaces.computeIfAbsent(rev.appname, k -> Sets.newConcurrentHashSet()) + appInterfaces.computeIfAbsent(rev.getAppName(), k -> Sets.newConcurrentHashSet()) .add(dataInfoId); } - registry.put(rev.revision, rev); + registry.put(rev.getRevision(), rev); } private String generateKeysDigest() { diff --git a/server/server/session/src/main/java/com/alipay/sofa/registry/server/session/cache/SessionDatumCacheDecorator.java b/server/server/session/src/main/java/com/alipay/sofa/registry/server/session/cache/SessionDatumCacheDecorator.java index 2c50eb0be..7c2ff4786 100644 --- a/server/server/session/src/main/java/com/alipay/sofa/registry/server/session/cache/SessionDatumCacheDecorator.java +++ b/server/server/session/src/main/java/com/alipay/sofa/registry/server/session/cache/SessionDatumCacheDecorator.java @@ -30,6 +30,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; +import java.util.Set; import java.util.stream.Collectors; /** @@ -112,7 +113,7 @@ public Map getDatumsCache(String dataInfoId) { public Map> getAppDatumCache(String dataInfoId, String instanceId) { Map> result = new HashMap<>(); //get metadata from session cache - for (String appName : appRevisionCacheRegistry.getApps(dataInfoId)) { + for (String appName : appRevisionCacheRegistry.getAppRevisions(dataInfoId).keySet()) { String appDataInfoId = DataInfo.toDataInfoId(appName, instanceId, ValueConstants.SOFA_APP); Map appDatum = this.getDatumsCache(appDataInfoId); diff --git a/server/server/session/src/main/java/com/alipay/sofa/registry/server/session/converter/AppPublisherConverter.java b/server/server/session/src/main/java/com/alipay/sofa/registry/server/session/converter/AppPublisherConverter.java index 30638fdee..ef9eb4851 100644 --- a/server/server/session/src/main/java/com/alipay/sofa/registry/server/session/converter/AppPublisherConverter.java +++ b/server/server/session/src/main/java/com/alipay/sofa/registry/server/session/converter/AppPublisherConverter.java @@ -21,15 +21,20 @@ import com.alipay.sofa.registry.common.model.store.AppPublisher; import com.alipay.sofa.registry.common.model.store.DataInfo; import com.alipay.sofa.registry.common.model.store.Publisher; +import com.alipay.sofa.registry.core.model.AppRevisionInterface; import com.alipay.sofa.registry.core.model.AppRevisionRegister; import com.alipay.sofa.registry.server.session.cache.AppRevisionCacheRegistry; +import com.alipay.sofa.registry.server.session.utils.AddressUtil; +import com.google.common.collect.ArrayListMultimap; +import org.springframework.util.CollectionUtils; -import javax.ws.rs.core.UriBuilder; -import javax.xml.crypto.Data; import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; /** * @author xiaojian.xj @@ -47,40 +52,46 @@ public static Publisher convert(AppPublisher appPublisher, for (AppRegisterServerDataBox appRegisterServerDataBox : appPublisher.getAppDataList()) { AppRevisionRegister revisionRegister = appRevisionCacheRegistry .getRevision(appRegisterServerDataBox.getRevision()); - Map> params = extractParams(revisionRegister, + if (!revisionRegister.getInterfaces().containsKey(dataInfoId)) { + continue; + } + Map> params = extractParams(revisionRegister, appRegisterServerDataBox, dataInfoId); - dataList.add(new ServerDataBox(buildURL(appRegisterServerDataBox.getUrl(), params))); + dataList.add(new ServerDataBox(AddressUtil.buildURL(appRegisterServerDataBox.getUrl(), + params))); } publisher.setDataList(dataList); return publisher; } - private static Map> extractParams(AppRevisionRegister revisionRegister, - AppRegisterServerDataBox serverDataBox, - String dataInfoId) { - Map> params = new HashMap<>(); - params.putAll(revisionRegister.baseParams); - if (revisionRegister.interfaces.containsKey(dataInfoId)) { - params.putAll(revisionRegister.interfaces.get(dataInfoId).serviceParams); + private static Map> extractParams(AppRevisionRegister revisionRegister, + AppRegisterServerDataBox serverDataBox, + String dataInfoId) { + ArrayListMultimap multimap = ArrayListMultimap.create(); + + combineParams(revisionRegister.getBaseParams(), multimap); + combineParams(serverDataBox.getBaseParams(), multimap); + + if (!CollectionUtils.isEmpty(revisionRegister.getInterfaces())) { + AppRevisionInterface appRevisionInterface = revisionRegister.getInterfaces().get( + dataInfoId); + if (appRevisionInterface != null) { + combineParams(appRevisionInterface.getServiceParams(), multimap); + } } - params.putAll(serverDataBox.getBaseParams()); - if (serverDataBox.getServiceParams().containsKey(dataInfoId)) { - params.putAll(serverDataBox.getServiceParams().get(dataInfoId)); + if (!CollectionUtils.isEmpty(serverDataBox.getInterfaceParams())) { + Map> params = serverDataBox.getInterfaceParams().get(dataInfoId); + combineParams(params, multimap); } - return params; + return multimap.asMap(); } - private static String buildURL(String address, Map> params) { - List querys = new ArrayList<>(); - for (Map.Entry> entry : params.entrySet()) { - String key = entry.getKey(); - for (String value : entry.getValue()) { - querys.add(key + "=" + value); - } + private static void combineParams(Map> params, ArrayListMultimap multimap) { + if (CollectionUtils.isEmpty(params)) { + return; } - String queryStr = String.join("&", querys); - return address + "?" + queryStr; + params.forEach((key, value) -> multimap.putAll(key, value)); } private static void fillCommonRegion(Publisher publisher, AppPublisher source, DataInfo dataInfo) { diff --git a/server/server/session/src/main/java/com/alipay/sofa/registry/server/session/converter/PublisherConverter.java b/server/server/session/src/main/java/com/alipay/sofa/registry/server/session/converter/PublisherConverter.java index 4add32d22..1bc8a1117 100644 --- a/server/server/session/src/main/java/com/alipay/sofa/registry/server/session/converter/PublisherConverter.java +++ b/server/server/session/src/main/java/com/alipay/sofa/registry/server/session/converter/PublisherConverter.java @@ -27,12 +27,10 @@ import com.alipay.sofa.registry.common.model.store.URL; import com.alipay.sofa.registry.core.model.DataBox; import com.alipay.sofa.registry.core.model.PublisherRegister; -import com.google.common.collect.ArrayListMultimap; import org.apache.commons.lang.StringUtils; import org.springframework.util.CollectionUtils; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; /** @@ -124,12 +122,7 @@ private static List convert2AppDataList(List } for (DataBox dataBox : dataList) { - AppRegisterServerDataBox serverDataBox = new AppRegisterServerDataBox(); - JSONObject jsonObject = JSON.parseObject(dataBox.getData()); - serverDataBox.setUrl(jsonObject.getString(AppRegisterConstant.URL_KEY)); - serverDataBox.setRevision(jsonObject.getString(AppRegisterConstant.REVISION_KEY)); - serverDataBox.setBaseParams(JSONObject.parseObject(jsonObject.getString(AppRegisterConstant.BASE_PARAMS_KEY), HashMap.class)); - serverDataBox.setServiceParams(JSONObject.parseObject(jsonObject.getString(AppRegisterConstant.INTERFACE_PARAMS_KEY), HashMap.class)); + AppRegisterServerDataBox serverDataBox = JSONObject.parseObject(dataBox.getData(), AppRegisterServerDataBox.class); dataBoxes.add(serverDataBox); } diff --git a/server/server/session/src/main/java/com/alipay/sofa/registry/server/session/predicate/RevisionPredicate.java b/server/server/session/src/main/java/com/alipay/sofa/registry/server/session/predicate/RevisionPredicate.java index 8ff5aa251..0c00e0c51 100644 --- a/server/server/session/src/main/java/com/alipay/sofa/registry/server/session/predicate/RevisionPredicate.java +++ b/server/server/session/src/main/java/com/alipay/sofa/registry/server/session/predicate/RevisionPredicate.java @@ -39,7 +39,7 @@ public Predicate revisionPredicate(String dataInfoId) { if (revisionRegister == null) { return false; } - if (!revisionRegister.interfaces.containsKey(dataInfoId)) { + if (!revisionRegister.getInterfaces().containsKey(dataInfoId)) { return false; } return true; diff --git a/server/server/session/src/main/java/com/alipay/sofa/registry/server/session/registry/SessionRegistry.java b/server/server/session/src/main/java/com/alipay/sofa/registry/server/session/registry/SessionRegistry.java index 66f3a781b..a9940c5e8 100644 --- a/server/server/session/src/main/java/com/alipay/sofa/registry/server/session/registry/SessionRegistry.java +++ b/server/server/session/src/main/java/com/alipay/sofa/registry/server/session/registry/SessionRegistry.java @@ -17,7 +17,6 @@ package com.alipay.sofa.registry.server.session.registry; import com.alipay.sofa.registry.common.model.ConnectId; -import com.alipay.sofa.registry.common.model.store.*; import java.util.*; import java.util.concurrent.TimeUnit; @@ -118,6 +117,8 @@ public class SessionRegistry implements Registry { @Autowired private SlotTableCache slotTableCache; + + @Autowired private AppRevisionCacheRegistry appRevisionCacheRegistry; private volatile boolean enableDataRenewSnapshot = true; @@ -273,7 +274,7 @@ public void fetchChangDataProcess() { for (String dataInfoId : checkDataInfoIds) { fetchDataInfoIds.add(dataInfoId); - fetchDataInfoIds.addAll(appRevisionCacheRegistry.getApps(dataInfoId)); + fetchDataInfoIds.addAll(appRevisionCacheRegistry.getAppRevisions(dataInfoId).keySet()); } LOGGER.info("[fetchChangDataProcess] Fetch data versions for {} dataInfoIds", diff --git a/server/server/session/src/test/java/com/alipay/sofa/registry/server/session/store/AppPublisherConverterTest.java b/server/server/session/src/test/java/com/alipay/sofa/registry/server/session/store/AppPublisherConverterTest.java index 9a2d8d799..b2ceb45f4 100644 --- a/server/server/session/src/test/java/com/alipay/sofa/registry/server/session/store/AppPublisherConverterTest.java +++ b/server/server/session/src/test/java/com/alipay/sofa/registry/server/session/store/AppPublisherConverterTest.java @@ -45,13 +45,19 @@ public void testConvert() { serverDataBox.setRevision(jsonObject.getString(AppRegisterConstant.REVISION_KEY)); serverDataBox.setBaseParams(JSONObject.parseObject( jsonObject.getString(AppRegisterConstant.BASE_PARAMS_KEY), HashMap.class)); - serverDataBox.setServiceParams(JSONObject.parseObject( + serverDataBox.setInterfaceParams(JSONObject.parseObject( jsonObject.getString(AppRegisterConstant.INTERFACE_PARAMS_KEY), HashMap.class)); Assert.assertEquals(serverDataBox.getBaseParams().get("a").size(), 1); Assert.assertEquals( - serverDataBox.getServiceParams() + serverDataBox.getInterfaceParams() .get("com.alipay.test.Simple5#@#DEFAULT_INSTANCE_ID#@#DEFAULT_GROUP").get("b") .size(), 2); + AppRegisterServerDataBox dataBox = JSONObject.parseObject(box, + AppRegisterServerDataBox.class); + Assert.assertEquals( + dataBox.getInterfaceParams() + .get("com.alipay.test.Simple5#@#DEFAULT_INSTANCE_ID#@#DEFAULT_GROUP").get("b") + .size(), 2); } } \ No newline at end of file