Skip to content

Commit

Permalink
[app_discovery] support subscribe app and interface publisher
Browse files Browse the repository at this point in the history
  • Loading branch information
nocvalight authored and dzdx committed Dec 16, 2020
1 parent 58a06ac commit 55d87c2
Show file tree
Hide file tree
Showing 60 changed files with 2,416 additions and 398 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

/**
* The type Subscriber process event.
* @author zhuoyu.sjw
* @auThor zhuoyu.sjw
* @version $Id : SubscriberProcessEvent.java, v 0.1 2018-07-13 18:40 zhuoyu.sjw Exp $$
*/
public class SubscriberProcessEvent implements Event {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import java.util.Map;

public class AppRevisionRegister implements Serializable {
public String revision;
public String appname;
public Map<String, String> baseParams;
public List<AppRevisionInterface> interfaces;
public String revision;
public String appname;
public Map<String, List<String>> baseParams;
public Map<String, AppRevisionInterface> interfaces;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alipay.sofa.registry.core.model;

/**
*
* @author xiaojian.xj
* @version $Id: AssembleType.java, v 0.1 2020年10月27日 01:51 xiaojian.xj Exp $
*/
public enum AssembleType {

/** sub app: only sub data where dataId = app */
sub_app,

/** sub interface: only sub data where dataId = interface */
sub_interface,

/** sub app and interface: sub data from app and interface */
sub_app_and_interface, ;

public static boolean contains(String name) {
for (AssembleType subDataType : values()) {
if (subDataType.name().equals(name)) {
return true;
}
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ public class SubscriberRegister extends BaseRegister {

private String scope;

/**
* interface: only sub interface
* app: only sub app
* app_and_interface: sub app and interface
*/
private String assembleType;

/**
* Getter method for property <tt>scope</tt>.
*
Expand All @@ -44,6 +51,24 @@ public void setScope(String scope) {
this.scope = scope;
}

/**
* Getter method for property <tt>assembleType</tt>.
*
* @return property value of assembleType
*/
public String getAssembleType() {
return assembleType;
}

/**
* Setter method for property <tt>assembleType</tt>.
*
* @param assembleType value to be assigned to property assembleType
*/
public void setAssembleType(String assembleType) {
this.assembleType = assembleType;
}

/**
* To string string.
*
Expand Down
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,13 @@
<rocksdbjni.version>6.4.6</rocksdbjni.version>
<main.user.dir>${user.dir}</main.user.dir>
<argLine>-Dnetwork_interface_denylist=docker0</argLine>
<<<<<<< HEAD
<!-- for linke 添加isSkipUT, isSkipIT参数声明,防止编译时产生错误 -->
<isSkipUT>false</isSkipUT>
<isSkipIT>false</isSkipIT>
=======
<fastjson.version>1.2.51.sec09_noneautotype</fastjson.version>
>>>>>>> [app_discovery] support subscribe app and interface publisher
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -322,6 +326,7 @@
<version>3.2.2</version>
</dependency>


<!-- junit -->
<dependency>
<groupId>junit</groupId>
Expand Down Expand Up @@ -352,6 +357,11 @@
<artifactId>rocksdbjni</artifactId>
<version>${rocksdbjni.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>${fastjson.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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;
import java.util.List;
import java.util.Map;

/**
*
* @author xiaojian.xj
* @version $Id: AppRegisterServerDataBox.java, v 0.1 2020年11月12日 11:14 xiaojian.xj Exp $
*/
public class AppRegisterServerDataBox implements Serializable {
private static final long serialVersionUID = -3615677271684611262L;

/** revision */
private String revision;

/** ip:port */
private String url;

/** baseParams */
private HashMap<String/*key*/, List<String>/*values*/> baseParams;

/** */
private Map<String/*service*/, Map<String/*key*/, List<String>/*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();
}

/**
* Getter method for property <tt>revision</tt>.
*
* @return property value of revision
*/
public String getRevision() {
return revision;
}

/**
* Setter method for property <tt>revision</tt>.
*
* @param revision value to be assigned to property revision
*/
public void setRevision(String revision) {
this.revision = WordCache.getInstance().getWordCache(revision);
}

/**
* Getter method for property <tt>url</tt>.
*
* @return property value of url
*/
public String getUrl() {
return url;
}

/**
* Setter method for property <tt>url</tt>.
*
* @param url value to be assigned to property url
*/
public void setUrl(String url) {
this.url = url;
}

/**
* Getter method for property <tt>baseParams</tt>.
*
* @return property value of baseParams
*/
public HashMap<String, List<String>> getBaseParams() {
return baseParams;
}

/**
* Setter method for property <tt>baseParams</tt>.
*
* @param baseParams value to be assigned to property baseParams
*/
public void setBaseParams(HashMap<String, List<String>> baseParams) {
this.baseParams = baseParams;
}

/**
* Getter method for property <tt>serviceParams</tt>.
*
* @return property value of serviceParams
*/
public Map<String, Map<String, List<String>>> getServiceParams() {
return serviceParams;
}

/**
* Setter method for property <tt>serviceParams</tt>.
*
* @param serviceParams value to be assigned to property serviceParams
*/
public void setServiceParams(Map<String, Map<String, List<String>>> serviceParams) {
this.serviceParams = serviceParams;
}
}
Loading

0 comments on commit 55d87c2

Please sign in to comment.