Merge pull request #5712 from alibaba/feature_support_grpc_core

Merge 2.X branch to develop
This commit is contained in:
杨翊 SionYang 2021-05-14 14:36:23 +08:00 committed by GitHub
commit 32febf1ca3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
773 changed files with 63483 additions and 8631 deletions

View File

@ -31,9 +31,9 @@ script:
- mvn clean -Premove-test-data
- mvn -Prelease-nacos -Dmaven.test.skip=true clean install -U
- mvn clean -Premove-test-data
- mvn clean install -Pcit-test
- mvn clean package -Pcit-test
- mvn clean -Premove-test-data
- mvn clean package -Pit-test
- mvn clean package -Pnit-test
- mvn clean -Premove-test-data
after_success:
- mvn clean package -Pit-test

28
NOTICE
View File

@ -52,3 +52,31 @@ https://github.com/Dynatrace/openkit-java
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.
------
This product has a bundle Protocol Buffers<72><73>
Protocol Buffers
=======================
Protocol Buffers for Go with Gadgets
Copyright (c) 2013, The GoGo Authors. All rights reserved.
http://github.com/gogo/protobuf
------
This product has a bundle Istio<69><6F>
Istio
=======================
Copyright 2018 Istio Authors
Licensed 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.

View File

@ -46,16 +46,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>

View File

@ -37,6 +37,11 @@ public class AddressServerAuthManager implements AuthManager {
return result;
}
@Override
public User loginRemote(Object request) throws AccessException {
return null;
}
@Override
public void auth(Permission permission, User user) throws AccessException {
}

View File

@ -31,12 +31,32 @@
<url>http://nacos.io</url>
<build>
<plugins>
<!-- reuse when you need to update grpc model -->
<!--<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.5.0</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:3.8.0:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.14.0:exe:${os.detected.classifier}</pluginArtifact>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>6</source>
<target>6</target>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
@ -55,6 +75,15 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
@ -64,5 +93,40 @@
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty-shaded</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-common-protos</artifactId>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>protoc-gen-grpc-java</artifactId>
<type>pom</type>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,59 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.ability;
import com.alibaba.nacos.api.config.ClientConfigAbility;
import com.alibaba.nacos.api.naming.ClientNamingAbility;
/**
* abilities of nacos client.
*
* @author liuzunfei
* @version $Id: ClientAbilities.java, v 0.1 2021年01月24日 00:09 AM liuzunfei Exp $
*/
public class ClientAbilities {
private ClientRemoteAbility remoteAbility = new ClientRemoteAbility();
private ClientConfigAbility configAbility = new ClientConfigAbility();
private ClientNamingAbility namingAbility = new ClientNamingAbility();
public ClientRemoteAbility getRemoteAbility() {
return remoteAbility;
}
public void setRemoteAbility(ClientRemoteAbility remoteAbility) {
this.remoteAbility = remoteAbility;
}
public ClientConfigAbility getConfigAbility() {
return configAbility;
}
public void setConfigAbility(ClientConfigAbility configAbility) {
this.configAbility = configAbility;
}
public ClientNamingAbility getNamingAbility() {
return namingAbility;
}
public void setNamingAbility(ClientNamingAbility namingAbility) {
this.namingAbility = namingAbility;
}
}

View File

@ -13,37 +13,27 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.nacos.test;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
package com.alibaba.nacos.api.ability;
/**
* Unit test for simple App.
* remote abilities of nacos client.
*
* @author liuzunfei
* @version $Id: ClientRemoteAbility.java, v 0.1 2021年01月24日 00:09 AM liuzunfei Exp $
*/
public class AppTest
extends TestCase {
public class ClientRemoteAbility {
/**
* Create the test case
*
* @param testName name of the test case
* if support remote connection.
*/
public AppTest(String testName) {
super(testName);
private boolean supportRemoteConnection;
public boolean isSupportRemoteConnection() {
return this.supportRemoteConnection;
}
/**
* @return the suite of tests being tested
*/
public static Test suite() {
return new TestSuite(AppTest.class);
}
/**
* Rigourous Test :-)
*/
public void testApp() {
assertTrue(true);
public void setSupportRemoteConnection(boolean supportRemoteConnection) {
this.supportRemoteConnection = supportRemoteConnection;
}
}

View File

@ -0,0 +1,80 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.ability;
import com.alibaba.nacos.api.config.ServerConfigAbility;
import com.alibaba.nacos.api.naming.ServerNamingAbility;
import java.io.Serializable;
import java.util.Objects;
/**
* abilities of nacos server.
*
* @author liuzunfei
* @version $Id: ServerAbilities.java, v 0.1 2021年01月24日 00:09 AM liuzunfei Exp $
*/
public class ServerAbilities implements Serializable {
private ServerRemoteAbility remoteAbility = new ServerRemoteAbility();
private ServerConfigAbility configAbility = new ServerConfigAbility();
private ServerNamingAbility namingAbility = new ServerNamingAbility();
public ServerRemoteAbility getRemoteAbility() {
return remoteAbility;
}
public void setRemoteAbility(ServerRemoteAbility remoteAbility) {
this.remoteAbility = remoteAbility;
}
public ServerConfigAbility getConfigAbility() {
return configAbility;
}
public void setConfigAbility(ServerConfigAbility configAbility) {
this.configAbility = configAbility;
}
public ServerNamingAbility getNamingAbility() {
return namingAbility;
}
public void setNamingAbility(ServerNamingAbility namingAbility) {
this.namingAbility = namingAbility;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ServerAbilities that = (ServerAbilities) o;
return Objects.equals(remoteAbility, that.remoteAbility) && Objects.equals(configAbility, that.configAbility)
&& Objects.equals(namingAbility, that.namingAbility);
}
@Override
public int hashCode() {
return Objects.hash(remoteAbility, configAbility, namingAbility);
}
}

View File

@ -0,0 +1,59 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.ability;
import java.io.Serializable;
import java.util.Objects;
/**
* remote abilities of nacos server.
*
* @author liuzunfei
* @version $Id: ServerRemoteAbility.java, v 0.1 2021年01月24日 00:09 AM liuzunfei Exp $
*/
public class ServerRemoteAbility implements Serializable {
/**
* if support remote connection.
*/
private boolean supportRemoteConnection;
public boolean isSupportRemoteConnection() {
return this.supportRemoteConnection;
}
public void setSupportRemoteConnection(boolean supportRemoteConnection) {
this.supportRemoteConnection = supportRemoteConnection;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ServerRemoteAbility that = (ServerRemoteAbility) o;
return supportRemoteConnection == that.supportRemoteConnection;
}
@Override
public int hashCode() {
return Objects.hash(supportRemoteConnection);
}
}

View File

@ -93,7 +93,7 @@ public interface CmdbService {
*
* @param entityName name of entity
* @param entityType type of entity
* @return
* @return entity.
*/
Entity getEntity(String entityName, String entityType);
}

View File

@ -196,4 +196,17 @@ public class Constants {
public static final String ALL_PATTERN = "*";
public static final String COLON = ":";
public static final String LINE_BREAK = "\n";
public static final String POUND = "#";
public static final String VIPSERVER_TAG = "Vipserver-Tag";
public static final String AMORY_TAG = "Amory-Tag";
public static final String LOCATION_TAG = "Location-Tag";
public static final String CHARSET_KEY = "charset";
}

View File

@ -0,0 +1,39 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.config;
/**
* config abilities of nacos client.
*
* @author liuzunfei
* @version $Id: ClientConfigAbility.java, v 0.1 2021年01月24日 00:09 AM liuzunfei Exp $
*/
public class ClientConfigAbility {
/**
* support remote metrics get.
*/
private boolean supportRemoteMetrics;
public boolean isSupportRemoteMetrics() {
return supportRemoteMetrics;
}
public void setSupportRemoteMetrics(boolean supportRemoteMetrics) {
this.supportRemoteMetrics = supportRemoteMetrics;
}
}

View File

@ -79,6 +79,7 @@ public interface ConfigService {
*/
boolean publishConfig(String dataId, String group, String content) throws NacosException;
/**
* Publish config.
*
@ -91,6 +92,32 @@ public interface ConfigService {
*/
boolean publishConfig(String dataId, String group, String content, String type) throws NacosException;
/**
* Cas Publish config.
*
* @param dataId dataId
* @param group group
* @param content content
* @param casMd5 casMd5 prev content's md5 to cas.
* @return Whether publish
* @throws NacosException NacosException
*/
boolean publishConfigCas(String dataId, String group, String content, String casMd5) throws NacosException;
/**
* Cas Publish config.
*
* @param dataId dataId
* @param group group
* @param content content
* @param casMd5 casMd5 prev content's md5 to cas.
* @param type config type {@link ConfigType}
* @return Whether publish
* @throws NacosException NacosException
*/
boolean publishConfigCas(String dataId, String group, String content, String casMd5, String type)
throws NacosException;
/**
* Remove config.
*

View File

@ -0,0 +1,59 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.config;
import java.io.Serializable;
import java.util.Objects;
/**
* config abilities of nacos server.
*
* @author liuzunfei
* @version $Id: ServerConfigAbility.java, v 0.1 2021年01月24日 00:09 AM liuzunfei Exp $
*/
public class ServerConfigAbility implements Serializable {
/**
* support remote metrics get.
*/
private boolean supportRemoteMetrics;
public boolean isSupportRemoteMetrics() {
return supportRemoteMetrics;
}
public void setSupportRemoteMetrics(boolean supportRemoteMetrics) {
this.supportRemoteMetrics = supportRemoteMetrics;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ServerConfigAbility that = (ServerConfigAbility) o;
return supportRemoteMetrics == that.supportRemoteMetrics;
}
@Override
public int hashCode() {
return Objects.hash(supportRemoteMetrics);
}
}

View File

@ -0,0 +1,32 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.config.remote.request;
import com.alibaba.nacos.api.remote.request.Request;
/**
* abstract request of config module request,all config module request should extends this class.
* @author liuzunfei
* @version $Id: ConfigCommonRequest.java, v 0.1 2020年07月13日 9:05 PM liuzunfei Exp $
*/
public abstract class AbstractConfigRequest extends Request {
@Override
public String getModule() {
return "config";
}
}

View File

@ -0,0 +1,112 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.config.remote.request;
import com.alibaba.nacos.api.remote.request.ServerRequest;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* request of config module metrics.
*
* @author liuzunfei
* @version $Id: ClientConfigMetricRequest.java, v 0.1 2020年12月30日 9:05 PM liuzunfei Exp $
*/
public class ClientConfigMetricRequest extends ServerRequest {
private List<MetricsKey> metricsKeys = new ArrayList<MetricsKey>();
@Override
public String getModule() {
return "config";
}
public List<MetricsKey> getMetricsKeys() {
return metricsKeys;
}
public void setMetricsKeys(List<MetricsKey> metricsKeys) {
this.metricsKeys = metricsKeys;
}
public static class MetricsKey implements Serializable {
String type;
String key;
public static final String CACHE_DATA = "cacheData";
public static final String SNAPSHOT_DATA = "snapshotData";
/**
* build metrics key.
*
* @param type type.
* @param key key.
* @return metric key.
*/
public static MetricsKey build(String type, String key) {
MetricsKey metricsKey = new MetricsKey();
metricsKey.type = type;
metricsKey.key = key;
return metricsKey;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
@Override
public String toString() {
return "MetricsKey{" + "type='" + type + '\'' + ", key='" + key + '\'' + '}';
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
MetricsKey that = (MetricsKey) o;
return Objects.equals(type, that.type) && Objects.equals(key, that.key);
}
@Override
public int hashCode() {
return Objects.hash(type, key);
}
}
}

View File

@ -0,0 +1,182 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.config.remote.request;
import java.util.ArrayList;
import java.util.List;
/**
* request of listening a batch of configs.
*
* @author liuzunfei
* @version $Id: ConfigBatchListenRequest.java, v 0.1 2020年07月27日 7:46 PM liuzunfei Exp $
*/
public class ConfigBatchListenRequest extends AbstractConfigRequest {
/**
* listen or remove listen.
*/
private boolean listen = true;
private List<ConfigListenContext> configListenContexts = new ArrayList<ConfigListenContext>();
/**
* add listen config.
*
* @param group group.
* @param dataId dataId.
* @param tenant tenant.
* @param md5 md5.
*/
public void addConfigListenContext(String group, String dataId, String tenant, String md5) {
ConfigListenContext configListenContext = new ConfigListenContext();
configListenContext.dataId = dataId;
configListenContext.group = group;
configListenContext.md5 = md5;
configListenContext.tenant = tenant;
configListenContexts.add(configListenContext);
}
/**
* Getter method for property <tt>configListenContexts</tt>.
*
* @return property value of configListenContexts
*/
public List<ConfigListenContext> getConfigListenContexts() {
return configListenContexts;
}
/**
* Setter method for property <tt>configListenContexts</tt>.
*
* @param configListenContexts value to be assigned to property configListenContexts
*/
public void setConfigListenContexts(List<ConfigListenContext> configListenContexts) {
this.configListenContexts = configListenContexts;
}
/**
* Getter method for property <tt>listen</tt>.
*
* @return property value of listen
*/
public boolean isListen() {
return listen;
}
/**
* Setter method for property <tt>listen</tt>.
*
* @param listen value to be assigned to property listen
*/
public void setListen(boolean listen) {
this.listen = listen;
}
public static class ConfigListenContext {
String group;
String md5;
String dataId;
String tenant;
public ConfigListenContext() {
}
@Override
public String toString() {
return "ConfigListenContext{" + "group='" + group + '\'' + ", md5='" + md5 + '\'' + ", dataId='" + dataId
+ '\'' + ", tenant='" + tenant + '\'' + '}';
}
/**
* Getter method for property <tt>group</tt>.
*
* @return property value of group
*/
public String getGroup() {
return group;
}
/**
* Setter method for property <tt>groupId</tt>.
*
* @param group value to be assigned to property groupId
*/
public void setGroup(String group) {
this.group = group;
}
/**
* Getter method for property <tt>md5</tt>.
*
* @return property value of md5
*/
public String getMd5() {
return md5;
}
/**
* Setter method for property <tt>md5</tt>.
*
* @param md5 value to be assigned to property md5
*/
public void setMd5(String md5) {
this.md5 = md5;
}
/**
* Getter method for property <tt>dataId</tt>.
*
* @return property value of dataId
*/
public String getDataId() {
return dataId;
}
/**
* Setter method for property <tt>dataId</tt>.
*
* @param dataId value to be assigned to property dataId
*/
public void setDataId(String dataId) {
this.dataId = dataId;
}
/**
* Getter method for property <tt>tenant</tt>.
*
* @return property value of tenant
*/
public String getTenant() {
return tenant;
}
/**
* Setter method for property <tt>tenant</tt>.
*
* @param tenant value to be assigned to property tenant
*/
public void setTenant(String tenant) {
this.tenant = tenant;
}
}
}

View File

@ -0,0 +1,79 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.config.remote.request;
import com.alibaba.nacos.api.remote.request.ServerRequest;
/**
* ConfigChangeNotifyRequest.
*
* @author liuzunfei
* @version $Id: ConfigChangeNotifyRequest.java, v 0.1 2020年07月14日 3:20 PM liuzunfei Exp $
*/
public class ConfigChangeNotifyRequest extends ServerRequest {
String dataId;
String group;
String tenant;
public String getDataId() {
return dataId;
}
public void setDataId(String dataId) {
this.dataId = dataId;
}
public String getGroup() {
return group;
}
public void setGroup(String group) {
this.group = group;
}
public String getTenant() {
return tenant;
}
public void setTenant(String tenant) {
this.tenant = tenant;
}
/**
* build success response.
*
* @param dataId dataId
* @param group group
* @param tenant tenant
* @return ConfigChangeNotifyResponse
*/
public static ConfigChangeNotifyRequest build(String dataId, String group, String tenant) {
ConfigChangeNotifyRequest request = new ConfigChangeNotifyRequest();
request.setDataId(dataId);
request.setGroup(group);
request.setTenant(tenant);
return request;
}
@Override
public String getModule() {
return "config";
}
}

View File

@ -0,0 +1,183 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.config.remote.request;
import java.util.HashMap;
import java.util.Map;
/**
* request to publish a config.
*
* @author liuzunfei
* @version $Id: ConfigPublishRequest.java, v 0.1 2020年07月16日 4:30 PM liuzunfei Exp $
*/
public class ConfigPublishRequest extends AbstractConfigRequest {
String dataId;
String group;
String tenant;
String content;
String casMd5;
private Map<String, String> additionMap;
public ConfigPublishRequest() {
}
/**
* get additional param.
*
* @param key key of param.
* @return value of param ,return null if not exist.
*/
public String getAdditionParam(String key) {
return additionMap == null ? null : additionMap.get(key);
}
/**
* put additional param value. will override if exist.
*
* @param key key of param.
* @param value value of param.
*/
public void putAdditionalParam(String key, String value) {
if (additionMap == null) {
additionMap = new HashMap<String, String>(2);
}
additionMap.put(key, value);
}
public ConfigPublishRequest(String dataId, String group, String tenant, String content) {
this.content = content;
this.dataId = dataId;
this.group = group;
this.tenant = tenant;
}
/**
* Getter method for property <tt>dataId</tt>.
*
* @return property value of dataId
*/
public String getDataId() {
return dataId;
}
/**
* Setter method for property <tt>dataId</tt>.
*
* @param dataId value to be assigned to property dataId
*/
public void setDataId(String dataId) {
this.dataId = dataId;
}
/**
* Getter method for property <tt>group</tt>.
*
* @return property value of group
*/
public String getGroup() {
return group;
}
/**
* Setter method for property <tt>group</tt>.
*
* @param group value to be assigned to property group
*/
public void setGroup(String group) {
this.group = group;
}
/**
* Getter method for property <tt>content</tt>.
*
* @return property value of content
*/
public String getContent() {
return content;
}
/**
* Setter method for property <tt>content</tt>.
*
* @param content value to be assigned to property content
*/
public void setContent(String content) {
this.content = content;
}
/**
* Getter method for property <tt>casMd5</tt>.
*
* @return property value of casMd5
*/
public String getCasMd5() {
return casMd5;
}
/**
* Setter method for property <tt>casMd5</tt>.
*
* @param casMd5 value to be assigned to property content
*/
public void setCasMd5(String casMd5) {
this.casMd5 = casMd5;
}
/**
* Getter method for property <tt>casMd5</tt>.
*
* @return property value of casMd5
*/
public Map<String, String> getAdditionMap() {
return additionMap;
}
/**
* Setter method for property <tt>additionMap</tt>.
*
* @param additionMap value to be assigned to property additionMap
*/
public void setAdditionMap(Map<String, String> additionMap) {
this.additionMap = additionMap;
}
/**
* Getter method for property <tt>tenant</tt>.
*
* @return property value of tenant
*/
public String getTenant() {
return tenant;
}
/**
* Setter method for property <tt>tenant</tt>.
*
* @param tenant value to be assigned to property tenant
*/
public void setTenant(String tenant) {
this.tenant = tenant;
}
}

View File

@ -0,0 +1,127 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.config.remote.request;
/**
* request to query config content.
*
* @author liuzunfei
* @version $Id: ConfigQueryRequest.java, v 0.1 2020年07月13日 9:06 PM liuzunfei Exp $
*/
public class ConfigQueryRequest extends AbstractConfigRequest {
private String dataId;
private String group;
private String tenant;
private String tag;
/**
* request builder.
*
* @param dataId dataId
* @param group group
* @param tenant tenant
* @return ConfigQueryRequest instance.
*/
public static ConfigQueryRequest build(String dataId, String group, String tenant) {
ConfigQueryRequest request = new ConfigQueryRequest();
request.setDataId(dataId);
request.setGroup(group);
request.setTenant(tenant);
return request;
}
/**
* Getter method for property <tt>dataId</tt>.
*
* @return property value of dataId
*/
public String getDataId() {
return dataId;
}
/**
* Setter method for property <tt>dataId</tt>.
*
* @param dataId value to be assigned to property dataId
*/
public void setDataId(String dataId) {
this.dataId = dataId;
}
/**
* Getter method for property <tt>group</tt>.
*
* @return property value of group
*/
public String getGroup() {
return group;
}
/**
* Setter method for property <tt>group</tt>.
*
* @param group value to be assigned to property group
*/
public void setGroup(String group) {
this.group = group;
}
/**
* Getter method for property <tt>tenant</tt>.
*
* @return property value of tenant
*/
public String getTenant() {
return tenant;
}
/**
* Setter method for property <tt>tenant</tt>.
*
* @param tenant value to be assigned to property tenant
*/
public void setTenant(String tenant) {
this.tenant = tenant;
}
/**
* Getter method for property <tt>tag</tt>.
*
* @return property value of tag
*/
public String getTag() {
return tag;
}
/**
* Setter method for property <tt>tag</tt>.
*
* @param tag value to be assigned to property tag
*/
public void setTag(String tag) {
this.tag = tag;
}
public boolean isNotify() {
String notify = getHeader("notify", "false");
return Boolean.valueOf(notify);
}
}

View File

@ -0,0 +1,117 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.config.remote.request;
/**
* request to remove a config .
*
* @author liuzunfei
* @version $Id: ConfigRemoveRequest.java, v 0.1 2020年07月16日 4:31 PM liuzunfei Exp $
*/
public class ConfigRemoveRequest extends AbstractConfigRequest {
String dataId;
String group;
String tenant;
String tag;
public ConfigRemoveRequest() {
}
public ConfigRemoveRequest(String dataId, String group, String tenant, String tag) {
this.dataId = dataId;
this.group = group;
this.tag = tag;
this.tenant = tenant;
}
/**
* Getter method for property <tt>dataId</tt>.
*
* @return property value of dataId
*/
public String getDataId() {
return dataId;
}
/**
* Getter method for property <tt>tag</tt>.
*
* @return property value of tag
*/
public String getTag() {
return tag;
}
/**
* Setter method for property <tt>tag</tt>.
*
* @param tag value to be assigned to property tag
*/
public void setTag(String tag) {
this.tag = tag;
}
/**
* Setter method for property <tt>dataId</tt>.
*
* @param dataId value to be assigned to property dataId
*/
public void setDataId(String dataId) {
this.dataId = dataId;
}
/**
* Getter method for property <tt>group</tt>.
*
* @return property value of group
*/
public String getGroup() {
return group;
}
/**
* Setter method for property <tt>group</tt>.
*
* @param group value to be assigned to property group
*/
public void setGroup(String group) {
this.group = group;
}
/**
* Getter method for property <tt>tenant</tt>.
*
* @return property value of tenant
*/
public String getTenant() {
return tenant;
}
/**
* Setter method for property <tt>tenant</tt>.
*
* @param tenant value to be assigned to property tenant
*/
public void setTenant(String tenant) {
this.tenant = tenant;
}
}

View File

@ -0,0 +1,139 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.config.remote.request.cluster;
import com.alibaba.nacos.api.config.remote.request.AbstractConfigRequest;
/**
* config change sync request on clusters.
*
* @author liuzunfei
* @version $Id: ConfigChangeClusterSyncRequest.java, v 0.1 2020年08月11日 4:30 PM liuzunfei Exp $
*/
public class ConfigChangeClusterSyncRequest extends AbstractConfigRequest {
String dataId;
String group;
String tenant;
String tag;
long lastModified;
boolean isBeta;
public boolean isBeta() {
return isBeta;
}
public void setBeta(boolean beta) {
isBeta = beta;
}
/**
* Getter method for property <tt>dataId</tt>.
*
* @return property value of dataId
*/
public String getDataId() {
return dataId;
}
/**
* Setter method for property <tt>dataId</tt>.
*
* @param dataId value to be assigned to property dataId
*/
public void setDataId(String dataId) {
this.dataId = dataId;
}
/**
* Getter method for property <tt>group</tt>.
*
* @return property value of group
*/
public String getGroup() {
return group;
}
/**
* Setter method for property <tt>group</tt>.
*
* @param group value to be assigned to property group
*/
public void setGroup(String group) {
this.group = group;
}
/**
* Getter method for property <tt>tenant</tt>.
*
* @return property value of tenant
*/
public String getTenant() {
return tenant;
}
/**
* Setter method for property <tt>tenant</tt>.
*
* @param tenant value to be assigned to property tenant
*/
public void setTenant(String tenant) {
this.tenant = tenant;
}
/**
* Getter method for property <tt>tag</tt>.
*
* @return property value of tag
*/
public String getTag() {
return tag;
}
/**
* Setter method for property <tt>tag</tt>.
*
* @param tag value to be assigned to property tag
*/
public void setTag(String tag) {
this.tag = tag;
}
/**
* Getter method for property <tt>lastModified</tt>.
*
* @return property value of lastModified
*/
public long getLastModified() {
return lastModified;
}
/**
* Setter method for property <tt>lastModified</tt>.
*
* @param lastModified value to be assigned to property lastModified
*/
public void setLastModified(long lastModified) {
this.lastModified = lastModified;
}
}

View File

@ -0,0 +1,46 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.config.remote.response;
import com.alibaba.nacos.api.remote.response.Response;
import java.util.HashMap;
import java.util.Map;
/**
* client config metrics response.
*
* @author liuzunfei
* @version $Id: ClientConfigMetricResponse.java, v 0.1 2020年12月30日 2:59 PM liuzunfei Exp $
*/
public class ClientConfigMetricResponse extends Response {
private Map<String, Object> metrics = new HashMap<>();
public Map<String, Object> getMetrics() {
return metrics;
}
public void setMetrics(Map<String, Object> metrics) {
this.metrics = metrics;
}
public void putMetric(String key, Object value) {
metrics.put(key, value);
}
}

View File

@ -0,0 +1,157 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.config.remote.response;
import com.alibaba.nacos.api.remote.response.Response;
import com.alibaba.nacos.api.remote.response.ResponseCode;
import java.util.ArrayList;
import java.util.List;
/**
* ConfigChangeBatchListenResponse.
*
* @author liuzunfei
* @version $Id: ConfigChangeBatchListenResponse.java, v 0.1 2020年07月14日 3:07 PM liuzunfei Exp $
*/
public class ConfigChangeBatchListenResponse extends Response {
List<ConfigContext> changedConfigs = new ArrayList<ConfigContext>();
public ConfigChangeBatchListenResponse() {
}
/**
* add changed config.
*
* @param dataId dataId.
* @param group group.
* @param tenant tenant.
*/
public void addChangeConfig(String dataId, String group, String tenant) {
ConfigContext configContext = new ConfigContext();
configContext.dataId = dataId;
configContext.group = group;
configContext.tenant = tenant;
changedConfigs.add(configContext);
}
/**
* Getter method for property <tt>changedConfigs</tt>.
*
* @return property value of changedConfigs
*/
public List<ConfigContext> getChangedConfigs() {
return changedConfigs;
}
/**
* Setter method for property <tt>changedConfigs</tt>.
*
* @param changedConfigs value to be assigned to property changedConfigs
*/
public void setChangedConfigs(List<ConfigContext> changedConfigs) {
this.changedConfigs = changedConfigs;
}
/**
* build fail response.
*
* @param errorMessage errorMessage.
* @return response.
*/
public static ConfigChangeBatchListenResponse buildFailResponse(String errorMessage) {
ConfigChangeBatchListenResponse response = new ConfigChangeBatchListenResponse();
response.setResultCode(ResponseCode.FAIL.getCode());
response.setMessage(errorMessage);
return response;
}
public static class ConfigContext {
String group;
String dataId;
String tenant;
public ConfigContext() {
}
/**
* Getter method for property <tt>groupId</tt>.
*
* @return property value of groupId
*/
public String getGroup() {
return group;
}
/**
* Setter method for property <tt>groupId</tt>.
*
* @param group value to be assigned to property groupId
*/
public void setGroup(String group) {
this.group = group;
}
/**
* Getter method for property <tt>dataId</tt>.
*
* @return property value of dataId
*/
public String getDataId() {
return dataId;
}
/**
* Setter method for property <tt>dataId</tt>.
*
* @param dataId value to be assigned to property dataId
*/
public void setDataId(String dataId) {
this.dataId = dataId;
}
/**
* Getter method for property <tt>tenant</tt>.
*
* @return property value of tenant
*/
public String getTenant() {
return tenant;
}
/**
* Setter method for property <tt>tenant</tt>.
*
* @param tenant value to be assigned to property tenant
*/
public void setTenant(String tenant) {
this.tenant = tenant;
}
@Override
public String toString() {
return "ConfigContext{" + "group='" + group + '\'' + ", dataId='" + dataId + '\'' + ", tenant='" + tenant
+ '\'' + '}';
}
}
}

View File

@ -0,0 +1,28 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.config.remote.response;
import com.alibaba.nacos.api.remote.response.Response;
/**
* config change notify response from client.
* @author liuzunfei
* @version $Id: ConfigChangeNotifyResponse.java, v 0.1 2020年09月01日 2:59 PM liuzunfei Exp $
*/
public class ConfigChangeNotifyResponse extends Response {
}

View File

@ -0,0 +1,54 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.config.remote.response;
import com.alibaba.nacos.api.remote.response.Response;
import com.alibaba.nacos.api.remote.response.ResponseCode;
/**
* ConfigPublishResponse.
*
* @author liuzunfei
* @version $Id: ConfigPubishResponse.java, v 0.1 2020年07月16日 4:59 PM liuzunfei Exp $
*/
public class ConfigPublishResponse extends Response {
public ConfigPublishResponse() {
super();
}
/**
* Build success response.
*
* @return response.
*/
public static ConfigPublishResponse buildSuccessResponse() {
return new ConfigPublishResponse();
}
/**
* Build fail response.
*
* @return response.
*/
public static ConfigPublishResponse buildFailResponse(String errorMsg) {
ConfigPublishResponse configPublishResponse = new ConfigPublishResponse();
configPublishResponse.setResultCode(ResponseCode.FAIL.getCode());
configPublishResponse.setMessage(errorMsg);
return configPublishResponse;
}
}

View File

@ -0,0 +1,150 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.config.remote.response;
import com.alibaba.nacos.api.remote.response.Response;
/**
* ConfigQueryResponse.
*
* @author liuzunfei
* @version $Id: ConfigQueryResponse.java, v 0.1 2020年07月14日 2:47 PM liuzunfei Exp $
*/
public class ConfigQueryResponse extends Response {
public static final int CONFIG_NOT_FOUND = 300;
public static final int CONFIG_QUERY_CONFLICT = 400;
String content;
String encryptedDataKey;
String contentType;
String md5;
long lastModified;
boolean isBeta;
String tag;
public ConfigQueryResponse() {
}
/**
* Build fail response.
*
* @param errorCode errorCode.
* @param message message.
* @return response.
*/
public static ConfigQueryResponse buildFailResponse(int errorCode, String message) {
ConfigQueryResponse response = new ConfigQueryResponse();
response.setErrorInfo(errorCode, message);
return response;
}
/**
* Build success response.
*
* @param content content.
* @return response.
*/
public static ConfigQueryResponse buildSuccessResponse(String content) {
ConfigQueryResponse response = new ConfigQueryResponse();
response.setContent(content);
return response;
}
public String getTag() {
return tag;
}
public void setTag(String tag) {
this.tag = tag;
}
public String getMd5() {
return md5;
}
public void setMd5(String md5) {
this.md5 = md5;
}
public long getLastModified() {
return lastModified;
}
public void setLastModified(long lastModified) {
this.lastModified = lastModified;
}
public boolean isBeta() {
return isBeta;
}
public void setBeta(boolean beta) {
isBeta = beta;
}
/**
* Getter method for property <tt>content</tt>.
*
* @return property value of content
*/
public String getContent() {
return content;
}
/**
* Setter method for property <tt>content</tt>.
*
* @param content value to be assigned to property content
*/
public void setContent(String content) {
this.content = content;
}
public void setEncryptedDataKey(String encryptedDataKey) {
this.encryptedDataKey = encryptedDataKey;
}
public String getEncryptedDataKey() {
return encryptedDataKey;
}
/**
* Getter method for property <tt>contentType</tt>.
*
* @return property value of contentType
*/
public String getContentType() {
return contentType;
}
/**
* Setter method for property <tt>contentType</tt>.
*
* @param contentType value to be assigned to property contentType
*/
public void setContentType(String contentType) {
this.contentType = contentType;
}
}

View File

@ -0,0 +1,54 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.config.remote.response;
import com.alibaba.nacos.api.remote.response.Response;
import com.alibaba.nacos.api.remote.response.ResponseCode;
/**
* ConfigPubishResponse.
*
* @author liuzunfei
* @version $Id: ConfigPubishResponse.java, v 0.1 2020年07月16日 4:59 PM liuzunfei Exp $
*/
public class ConfigRemoveResponse extends Response {
public ConfigRemoveResponse() {
super();
}
/**
* Build success response.
*
* @return response.
*/
public static ConfigRemoveResponse buildSuccessResponse() {
return new ConfigRemoveResponse();
}
/**
* Build fail response.
*
* @return response.
*/
public static ConfigRemoveResponse buildFailResponse(String errorMsg) {
ConfigRemoveResponse removeResponse = new ConfigRemoveResponse();
removeResponse.setResultCode(ResponseCode.FAIL.getCode());
removeResponse.setMessage(errorMsg);
return removeResponse;
}
}

View File

@ -0,0 +1,29 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.config.remote.response.cluster;
import com.alibaba.nacos.api.remote.response.Response;
/**
* config change sync response on clusters.
*
* @author liuzunfei
* @version $Id: ConfigChangeClusterSyncResponse.java, v 0.1 2020年08月11日 4:32 PM liuzunfei Exp $
*/
public class ConfigChangeClusterSyncResponse extends Response {
}

View File

@ -108,7 +108,12 @@ public class NacosException extends Exception {
public static final int CLIENT_INVALID_PARAM = -400;
/**
* over client threshold超过server端的限流阈值.
* client disconnect.
*/
public static final int CLIENT_DISCONNECT = -401;
/**
* over client threshold超过client端的限流阈值.
*/
public static final int CLIENT_OVER_THRESHOLD = -503;
@ -153,11 +158,28 @@ public class NacosException extends Exception {
*/
public static final int OVER_THRESHOLD = 503;
/**
* Server is not started.
*/
public static final int INVALID_SERVER_STATUS = 300;
/**
* Connection is not registered.
*/
public static final int UN_REGISTER = 301;
/**
* No Handler Found.
*/
public static final int NO_HANDLER = 302;
public static final int RESOURCE_NOT_FOUND = -404;
/**
* http client error code,
* ome exceptions that occurred when the use the Nacos RestTemplate and Nacos AsyncRestTemplate.
* http client error code, ome exceptions that occurred when the use the Nacos RestTemplate and Nacos
* AsyncRestTemplate.
*/
public static final int HTTP_CLIENT_ERROR_CODE = -500;
}

View File

@ -0,0 +1,286 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.grpc.auto;
import static io.grpc.MethodDescriptor.generateFullMethodName;
import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall;
import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
import static io.grpc.stub.ClientCalls.asyncUnaryCall;
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
import static io.grpc.stub.ClientCalls.blockingUnaryCall;
import static io.grpc.stub.ClientCalls.futureUnaryCall;
import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
import static io.grpc.stub.ServerCalls.asyncUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
/**
*/
@javax.annotation.Generated(
value = "by gRPC proto compiler (version 1.14.0)",
comments = "Source: nacos_grpc_service.proto")
public final class BiRequestStreamGrpc {
private BiRequestStreamGrpc() {}
public static final String SERVICE_NAME = "BiRequestStream";
// Static method descriptors that strictly reflect the proto.
private static volatile io.grpc.MethodDescriptor<com.alibaba.nacos.api.grpc.auto.Payload,
com.alibaba.nacos.api.grpc.auto.Payload> getRequestBiStreamMethod;
@io.grpc.stub.annotations.RpcMethod(
fullMethodName = SERVICE_NAME + '/' + "requestBiStream",
requestType = com.alibaba.nacos.api.grpc.auto.Payload.class,
responseType = com.alibaba.nacos.api.grpc.auto.Payload.class,
methodType = io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING)
public static io.grpc.MethodDescriptor<com.alibaba.nacos.api.grpc.auto.Payload,
com.alibaba.nacos.api.grpc.auto.Payload> getRequestBiStreamMethod() {
io.grpc.MethodDescriptor<com.alibaba.nacos.api.grpc.auto.Payload, com.alibaba.nacos.api.grpc.auto.Payload> getRequestBiStreamMethod;
if ((getRequestBiStreamMethod = BiRequestStreamGrpc.getRequestBiStreamMethod) == null) {
synchronized (BiRequestStreamGrpc.class) {
if ((getRequestBiStreamMethod = BiRequestStreamGrpc.getRequestBiStreamMethod) == null) {
BiRequestStreamGrpc.getRequestBiStreamMethod = getRequestBiStreamMethod =
io.grpc.MethodDescriptor.<com.alibaba.nacos.api.grpc.auto.Payload, com.alibaba.nacos.api.grpc.auto.Payload>newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING)
.setFullMethodName(generateFullMethodName(
"BiRequestStream", "requestBiStream"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
com.alibaba.nacos.api.grpc.auto.Payload.getDefaultInstance()))
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
com.alibaba.nacos.api.grpc.auto.Payload.getDefaultInstance()))
.setSchemaDescriptor(new BiRequestStreamMethodDescriptorSupplier("requestBiStream"))
.build();
}
}
}
return getRequestBiStreamMethod;
}
/**
* Creates a new async stub that supports all call types for the service
*/
public static BiRequestStreamStub newStub(io.grpc.Channel channel) {
return new BiRequestStreamStub(channel);
}
/**
* Creates a new blocking-style stub that supports unary and streaming output calls on the service
*/
public static BiRequestStreamBlockingStub newBlockingStub(
io.grpc.Channel channel) {
return new BiRequestStreamBlockingStub(channel);
}
/**
* Creates a new ListenableFuture-style stub that supports unary calls on the service
*/
public static BiRequestStreamFutureStub newFutureStub(
io.grpc.Channel channel) {
return new BiRequestStreamFutureStub(channel);
}
/**
*/
public static abstract class BiRequestStreamImplBase implements io.grpc.BindableService {
/**
* <pre>
* Sends a commonRequest
* </pre>
*/
public io.grpc.stub.StreamObserver<com.alibaba.nacos.api.grpc.auto.Payload> requestBiStream(
io.grpc.stub.StreamObserver<com.alibaba.nacos.api.grpc.auto.Payload> responseObserver) {
return asyncUnimplementedStreamingCall(getRequestBiStreamMethod(), responseObserver);
}
@Override public final io.grpc.ServerServiceDefinition bindService() {
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
.addMethod(
getRequestBiStreamMethod(),
asyncBidiStreamingCall(
new MethodHandlers<
com.alibaba.nacos.api.grpc.auto.Payload,
com.alibaba.nacos.api.grpc.auto.Payload>(
this, METHODID_REQUEST_BI_STREAM)))
.build();
}
}
/**
*/
public static final class BiRequestStreamStub extends io.grpc.stub.AbstractStub<BiRequestStreamStub> {
private BiRequestStreamStub(io.grpc.Channel channel) {
super(channel);
}
private BiRequestStreamStub(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
super(channel, callOptions);
}
@Override
protected BiRequestStreamStub build(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
return new BiRequestStreamStub(channel, callOptions);
}
/**
* <pre>
* Sends a commonRequest
* </pre>
*/
public io.grpc.stub.StreamObserver<com.alibaba.nacos.api.grpc.auto.Payload> requestBiStream(
io.grpc.stub.StreamObserver<com.alibaba.nacos.api.grpc.auto.Payload> responseObserver) {
return asyncBidiStreamingCall(
getChannel().newCall(getRequestBiStreamMethod(), getCallOptions()), responseObserver);
}
}
/**
*/
public static final class BiRequestStreamBlockingStub extends io.grpc.stub.AbstractStub<BiRequestStreamBlockingStub> {
private BiRequestStreamBlockingStub(io.grpc.Channel channel) {
super(channel);
}
private BiRequestStreamBlockingStub(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
super(channel, callOptions);
}
@Override
protected BiRequestStreamBlockingStub build(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
return new BiRequestStreamBlockingStub(channel, callOptions);
}
}
/**
*/
public static final class BiRequestStreamFutureStub extends io.grpc.stub.AbstractStub<BiRequestStreamFutureStub> {
private BiRequestStreamFutureStub(io.grpc.Channel channel) {
super(channel);
}
private BiRequestStreamFutureStub(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
super(channel, callOptions);
}
@Override
protected BiRequestStreamFutureStub build(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
return new BiRequestStreamFutureStub(channel, callOptions);
}
}
private static final int METHODID_REQUEST_BI_STREAM = 0;
private static final class MethodHandlers<Req, Resp> implements
io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
private final BiRequestStreamImplBase serviceImpl;
private final int methodId;
MethodHandlers(BiRequestStreamImplBase serviceImpl, int methodId) {
this.serviceImpl = serviceImpl;
this.methodId = methodId;
}
@Override
@SuppressWarnings("unchecked")
public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
switch (methodId) {
default:
throw new AssertionError();
}
}
@Override
@SuppressWarnings("unchecked")
public io.grpc.stub.StreamObserver<Req> invoke(
io.grpc.stub.StreamObserver<Resp> responseObserver) {
switch (methodId) {
case METHODID_REQUEST_BI_STREAM:
return (io.grpc.stub.StreamObserver<Req>) serviceImpl.requestBiStream(
(io.grpc.stub.StreamObserver<com.alibaba.nacos.api.grpc.auto.Payload>) responseObserver);
default:
throw new AssertionError();
}
}
}
private static abstract class BiRequestStreamBaseDescriptorSupplier
implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier {
BiRequestStreamBaseDescriptorSupplier() {}
@Override
public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
return com.alibaba.nacos.api.grpc.auto.NacosGrpcService.getDescriptor();
}
@Override
public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() {
return getFileDescriptor().findServiceByName("BiRequestStream");
}
}
private static final class BiRequestStreamFileDescriptorSupplier
extends BiRequestStreamBaseDescriptorSupplier {
BiRequestStreamFileDescriptorSupplier() {}
}
private static final class BiRequestStreamMethodDescriptorSupplier
extends BiRequestStreamBaseDescriptorSupplier
implements io.grpc.protobuf.ProtoMethodDescriptorSupplier {
private final String methodName;
BiRequestStreamMethodDescriptorSupplier(String methodName) {
this.methodName = methodName;
}
@Override
public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() {
return getServiceDescriptor().findMethodByName(methodName);
}
}
private static volatile io.grpc.ServiceDescriptor serviceDescriptor;
public static io.grpc.ServiceDescriptor getServiceDescriptor() {
io.grpc.ServiceDescriptor result = serviceDescriptor;
if (result == null) {
synchronized (BiRequestStreamGrpc.class) {
result = serviceDescriptor;
if (result == null) {
serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
.setSchemaDescriptor(new BiRequestStreamFileDescriptorSupplier())
.addMethod(getRequestBiStreamMethod())
.build();
}
}
}
return result;
}
}

View File

@ -0,0 +1,962 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.grpc.auto;
/**
* Protobuf type {@code Metadata}
*/
public final class Metadata extends
com.google.protobuf.GeneratedMessageV3 implements
// @@protoc_insertion_point(message_implements:Metadata)
MetadataOrBuilder {
private static final long serialVersionUID = 0L;
// Use Metadata.newBuilder() to construct.
private Metadata(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private Metadata() {
type_ = "";
clientIp_ = "";
}
@Override
@SuppressWarnings({"unused"})
protected Object newInstance(
UnusedPrivateParameter unused) {
return new Metadata();
}
@Override
public final com.google.protobuf.UnknownFieldSet
getUnknownFields() {
return this.unknownFields;
}
private Metadata(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
this();
if (extensionRegistry == null) {
throw new NullPointerException();
}
int mutable_bitField0_ = 0;
com.google.protobuf.UnknownFieldSet.Builder unknownFields =
com.google.protobuf.UnknownFieldSet.newBuilder();
try {
boolean done = false;
while (!done) {
int tag = input.readTag();
switch (tag) {
case 0:
done = true;
break;
case 26: {
String s = input.readStringRequireUtf8();
type_ = s;
break;
}
case 58: {
if (!((mutable_bitField0_ & 0x00000001) != 0)) {
headers_ = com.google.protobuf.MapField.newMapField(
HeadersDefaultEntryHolder.defaultEntry);
mutable_bitField0_ |= 0x00000001;
}
com.google.protobuf.MapEntry<String, String>
headers__ = input.readMessage(
HeadersDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry);
headers_.getMutableMap().put(
headers__.getKey(), headers__.getValue());
break;
}
case 66: {
String s = input.readStringRequireUtf8();
clientIp_ = s;
break;
}
default: {
if (!parseUnknownField(
input, unknownFields, extensionRegistry, tag)) {
done = true;
}
break;
}
}
}
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
throw e.setUnfinishedMessage(this);
} catch (java.io.IOException e) {
throw new com.google.protobuf.InvalidProtocolBufferException(
e).setUnfinishedMessage(this);
} finally {
this.unknownFields = unknownFields.build();
makeExtensionsImmutable();
}
}
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return NacosGrpcService.internal_static_Metadata_descriptor;
}
@SuppressWarnings({"rawtypes"})
@Override
protected com.google.protobuf.MapField internalGetMapField(
int number) {
switch (number) {
case 7:
return internalGetHeaders();
default:
throw new RuntimeException(
"Invalid map field number: " + number);
}
}
@Override
protected FieldAccessorTable
internalGetFieldAccessorTable() {
return NacosGrpcService.internal_static_Metadata_fieldAccessorTable
.ensureFieldAccessorsInitialized(
Metadata.class, Builder.class);
}
public static final int TYPE_FIELD_NUMBER = 3;
private volatile Object type_;
/**
* <code>string type = 3;</code>
*/
public String getType() {
Object ref = type_;
if (ref instanceof String) {
return (String) ref;
} else {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
String s = bs.toStringUtf8();
type_ = s;
return s;
}
}
/**
* <code>string type = 3;</code>
*/
public com.google.protobuf.ByteString
getTypeBytes() {
Object ref = type_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(String) ref);
type_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int CLIENTIP_FIELD_NUMBER = 8;
private volatile Object clientIp_;
/**
* <code>string clientIp = 8;</code>
*/
public String getClientIp() {
Object ref = clientIp_;
if (ref instanceof String) {
return (String) ref;
} else {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
String s = bs.toStringUtf8();
clientIp_ = s;
return s;
}
}
/**
* <code>string clientIp = 8;</code>
*/
public com.google.protobuf.ByteString
getClientIpBytes() {
Object ref = clientIp_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(String) ref);
clientIp_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int HEADERS_FIELD_NUMBER = 7;
private static final class HeadersDefaultEntryHolder {
static final com.google.protobuf.MapEntry<
String, String> defaultEntry =
com.google.protobuf.MapEntry
.<String, String>newDefaultInstance(
NacosGrpcService.internal_static_Metadata_HeadersEntry_descriptor,
com.google.protobuf.WireFormat.FieldType.STRING,
"",
com.google.protobuf.WireFormat.FieldType.STRING,
"");
}
private com.google.protobuf.MapField<
String, String> headers_;
private com.google.protobuf.MapField<String, String>
internalGetHeaders() {
if (headers_ == null) {
return com.google.protobuf.MapField.emptyMapField(
HeadersDefaultEntryHolder.defaultEntry);
}
return headers_;
}
public int getHeadersCount() {
return internalGetHeaders().getMap().size();
}
/**
* <code>map&lt;string, string&gt; headers = 7;</code>
*/
public boolean containsHeaders(
String key) {
if (key == null) { throw new NullPointerException(); }
return internalGetHeaders().getMap().containsKey(key);
}
/**
* Use {@link #getHeadersMap()} instead.
*/
@Deprecated
public java.util.Map<String, String> getHeaders() {
return getHeadersMap();
}
/**
* <code>map&lt;string, string&gt; headers = 7;</code>
*/
public java.util.Map<String, String> getHeadersMap() {
return internalGetHeaders().getMap();
}
/**
* <code>map&lt;string, string&gt; headers = 7;</code>
*/
public String getHeadersOrDefault(
String key,
String defaultValue) {
if (key == null) { throw new NullPointerException(); }
java.util.Map<String, String> map =
internalGetHeaders().getMap();
return map.containsKey(key) ? map.get(key) : defaultValue;
}
/**
* <code>map&lt;string, string&gt; headers = 7;</code>
*/
public String getHeadersOrThrow(
String key) {
if (key == null) { throw new NullPointerException(); }
java.util.Map<String, String> map =
internalGetHeaders().getMap();
if (!map.containsKey(key)) {
throw new IllegalArgumentException();
}
return map.get(key);
}
private byte memoizedIsInitialized = -1;
@Override
public final boolean isInitialized() {
byte isInitialized = memoizedIsInitialized;
if (isInitialized == 1) return true;
if (isInitialized == 0) return false;
memoizedIsInitialized = 1;
return true;
}
@Override
public void writeTo(com.google.protobuf.CodedOutputStream output)
throws java.io.IOException {
if (!getTypeBytes().isEmpty()) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 3, type_);
}
com.google.protobuf.GeneratedMessageV3
.serializeStringMapTo(
output,
internalGetHeaders(),
HeadersDefaultEntryHolder.defaultEntry,
7);
if (!getClientIpBytes().isEmpty()) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 8, clientIp_);
}
unknownFields.writeTo(output);
}
@Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (!getTypeBytes().isEmpty()) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, type_);
}
for (java.util.Map.Entry<String, String> entry
: internalGetHeaders().getMap().entrySet()) {
com.google.protobuf.MapEntry<String, String>
headers__ = HeadersDefaultEntryHolder.defaultEntry.newBuilderForType()
.setKey(entry.getKey())
.setValue(entry.getValue())
.build();
size += com.google.protobuf.CodedOutputStream
.computeMessageSize(7, headers__);
}
if (!getClientIpBytes().isEmpty()) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, clientIp_);
}
size += unknownFields.getSerializedSize();
memoizedSize = size;
return size;
}
@Override
public boolean equals(final Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof Metadata)) {
return super.equals(obj);
}
Metadata other = (Metadata) obj;
if (!getType()
.equals(other.getType())) return false;
if (!getClientIp()
.equals(other.getClientIp())) return false;
if (!internalGetHeaders().equals(
other.internalGetHeaders())) return false;
if (!unknownFields.equals(other.unknownFields)) return false;
return true;
}
@Override
public int hashCode() {
if (memoizedHashCode != 0) {
return memoizedHashCode;
}
int hash = 41;
hash = (19 * hash) + getDescriptor().hashCode();
hash = (37 * hash) + TYPE_FIELD_NUMBER;
hash = (53 * hash) + getType().hashCode();
hash = (37 * hash) + CLIENTIP_FIELD_NUMBER;
hash = (53 * hash) + getClientIp().hashCode();
if (!internalGetHeaders().getMap().isEmpty()) {
hash = (37 * hash) + HEADERS_FIELD_NUMBER;
hash = (53 * hash) + internalGetHeaders().hashCode();
}
hash = (29 * hash) + unknownFields.hashCode();
memoizedHashCode = hash;
return hash;
}
public static Metadata parseFrom(
java.nio.ByteBuffer data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static Metadata parseFrom(
java.nio.ByteBuffer data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static Metadata parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static Metadata parseFrom(
com.google.protobuf.ByteString data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static Metadata parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static Metadata parseFrom(
byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static Metadata parseFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static Metadata parseFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input, extensionRegistry);
}
public static Metadata parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input);
}
public static Metadata parseDelimitedFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input, extensionRegistry);
}
public static Metadata parseFrom(
com.google.protobuf.CodedInputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static Metadata parseFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input, extensionRegistry);
}
@Override
public Builder newBuilderForType() { return newBuilder(); }
public static Builder newBuilder() {
return DEFAULT_INSTANCE.toBuilder();
}
public static Builder newBuilder(Metadata prototype) {
return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
}
@Override
public Builder toBuilder() {
return this == DEFAULT_INSTANCE
? new Builder() : new Builder().mergeFrom(this);
}
@Override
protected Builder newBuilderForType(
BuilderParent parent) {
Builder builder = new Builder(parent);
return builder;
}
/**
* Protobuf type {@code Metadata}
*/
public static final class Builder extends
com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
// @@protoc_insertion_point(builder_implements:Metadata)
MetadataOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return NacosGrpcService.internal_static_Metadata_descriptor;
}
@SuppressWarnings({"rawtypes"})
protected com.google.protobuf.MapField internalGetMapField(
int number) {
switch (number) {
case 7:
return internalGetHeaders();
default:
throw new RuntimeException(
"Invalid map field number: " + number);
}
}
@SuppressWarnings({"rawtypes"})
protected com.google.protobuf.MapField internalGetMutableMapField(
int number) {
switch (number) {
case 7:
return internalGetMutableHeaders();
default:
throw new RuntimeException(
"Invalid map field number: " + number);
}
}
@Override
protected FieldAccessorTable
internalGetFieldAccessorTable() {
return NacosGrpcService.internal_static_Metadata_fieldAccessorTable
.ensureFieldAccessorsInitialized(
Metadata.class, Builder.class);
}
// Construct using com.alibaba.nacos.api.grpc.auto.Metadata.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private Builder(
BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessageV3
.alwaysUseFieldBuilders) {
}
}
@Override
public Builder clear() {
super.clear();
type_ = "";
clientIp_ = "";
internalGetMutableHeaders().clear();
return this;
}
@Override
public com.google.protobuf.Descriptors.Descriptor
getDescriptorForType() {
return NacosGrpcService.internal_static_Metadata_descriptor;
}
@Override
public Metadata getDefaultInstanceForType() {
return Metadata.getDefaultInstance();
}
@Override
public Metadata build() {
Metadata result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@Override
public Metadata buildPartial() {
Metadata result = new Metadata(this);
int from_bitField0_ = bitField0_;
result.type_ = type_;
result.clientIp_ = clientIp_;
result.headers_ = internalGetHeaders();
result.headers_.makeImmutable();
onBuilt();
return result;
}
@Override
public Builder clone() {
return super.clone();
}
@Override
public Builder setField(
com.google.protobuf.Descriptors.FieldDescriptor field,
Object value) {
return super.setField(field, value);
}
@Override
public Builder clearField(
com.google.protobuf.Descriptors.FieldDescriptor field) {
return super.clearField(field);
}
@Override
public Builder clearOneof(
com.google.protobuf.Descriptors.OneofDescriptor oneof) {
return super.clearOneof(oneof);
}
@Override
public Builder setRepeatedField(
com.google.protobuf.Descriptors.FieldDescriptor field,
int index, Object value) {
return super.setRepeatedField(field, index, value);
}
@Override
public Builder addRepeatedField(
com.google.protobuf.Descriptors.FieldDescriptor field,
Object value) {
return super.addRepeatedField(field, value);
}
@Override
public Builder mergeFrom(com.google.protobuf.Message other) {
if (other instanceof Metadata) {
return mergeFrom((Metadata)other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(Metadata other) {
if (other == Metadata.getDefaultInstance()) return this;
if (!other.getType().isEmpty()) {
type_ = other.type_;
onChanged();
}
if (!other.getClientIp().isEmpty()) {
clientIp_ = other.clientIp_;
onChanged();
}
internalGetMutableHeaders().mergeFrom(
other.internalGetHeaders());
this.mergeUnknownFields(other.unknownFields);
onChanged();
return this;
}
@Override
public final boolean isInitialized() {
return true;
}
@Override
public Builder mergeFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
Metadata parsedMessage = null;
try {
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
parsedMessage = (Metadata) e.getUnfinishedMessage();
throw e.unwrapIOException();
} finally {
if (parsedMessage != null) {
mergeFrom(parsedMessage);
}
}
return this;
}
private int bitField0_;
private Object type_ = "";
/**
* <code>string type = 3;</code>
*/
public String getType() {
Object ref = type_;
if (!(ref instanceof String)) {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
String s = bs.toStringUtf8();
type_ = s;
return s;
} else {
return (String) ref;
}
}
/**
* <code>string type = 3;</code>
*/
public com.google.protobuf.ByteString
getTypeBytes() {
Object ref = type_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(String) ref);
type_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
* <code>string type = 3;</code>
*/
public Builder setType(
String value) {
if (value == null) {
throw new NullPointerException();
}
type_ = value;
onChanged();
return this;
}
/**
* <code>string type = 3;</code>
*/
public Builder clearType() {
type_ = getDefaultInstance().getType();
onChanged();
return this;
}
/**
* <code>string type = 3;</code>
*/
public Builder setTypeBytes(
com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
type_ = value;
onChanged();
return this;
}
private Object clientIp_ = "";
/**
* <code>string clientIp = 8;</code>
*/
public String getClientIp() {
Object ref = clientIp_;
if (!(ref instanceof String)) {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
String s = bs.toStringUtf8();
clientIp_ = s;
return s;
} else {
return (String) ref;
}
}
/**
* <code>string clientIp = 8;</code>
*/
public com.google.protobuf.ByteString
getClientIpBytes() {
Object ref = clientIp_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(String) ref);
clientIp_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
* <code>string clientIp = 8;</code>
*/
public Builder setClientIp(
String value) {
if (value == null) {
throw new NullPointerException();
}
clientIp_ = value;
onChanged();
return this;
}
/**
* <code>string clientIp = 8;</code>
*/
public Builder clearClientIp() {
clientIp_ = getDefaultInstance().getClientIp();
onChanged();
return this;
}
/**
* <code>string clientIp = 8;</code>
*/
public Builder setClientIpBytes(
com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
clientIp_ = value;
onChanged();
return this;
}
private com.google.protobuf.MapField<
String, String> headers_;
private com.google.protobuf.MapField<String, String>
internalGetHeaders() {
if (headers_ == null) {
return com.google.protobuf.MapField.emptyMapField(
HeadersDefaultEntryHolder.defaultEntry);
}
return headers_;
}
private com.google.protobuf.MapField<String, String>
internalGetMutableHeaders() {
onChanged();;
if (headers_ == null) {
headers_ = com.google.protobuf.MapField.newMapField(
HeadersDefaultEntryHolder.defaultEntry);
}
if (!headers_.isMutable()) {
headers_ = headers_.copy();
}
return headers_;
}
public int getHeadersCount() {
return internalGetHeaders().getMap().size();
}
/**
* <code>map&lt;string, string&gt; headers = 7;</code>
*/
public boolean containsHeaders(
String key) {
if (key == null) { throw new NullPointerException(); }
return internalGetHeaders().getMap().containsKey(key);
}
/**
* Use {@link #getHeadersMap()} instead.
*/
@Deprecated
public java.util.Map<String, String> getHeaders() {
return getHeadersMap();
}
/**
* <code>map&lt;string, string&gt; headers = 7;</code>
*/
public java.util.Map<String, String> getHeadersMap() {
return internalGetHeaders().getMap();
}
/**
* <code>map&lt;string, string&gt; headers = 7;</code>
*/
public String getHeadersOrDefault(
String key,
String defaultValue) {
if (key == null) { throw new NullPointerException(); }
java.util.Map<String, String> map =
internalGetHeaders().getMap();
return map.containsKey(key) ? map.get(key) : defaultValue;
}
/**
* <code>map&lt;string, string&gt; headers = 7;</code>
*/
public String getHeadersOrThrow(
String key) {
if (key == null) { throw new NullPointerException(); }
java.util.Map<String, String> map =
internalGetHeaders().getMap();
if (!map.containsKey(key)) {
throw new IllegalArgumentException();
}
return map.get(key);
}
public Builder clearHeaders() {
internalGetMutableHeaders().getMutableMap()
.clear();
return this;
}
/**
* <code>map&lt;string, string&gt; headers = 7;</code>
*/
public Builder removeHeaders(
String key) {
if (key == null) { throw new NullPointerException(); }
internalGetMutableHeaders().getMutableMap()
.remove(key);
return this;
}
/**
* Use alternate mutation accessors instead.
*/
@Deprecated
public java.util.Map<String, String>
getMutableHeaders() {
return internalGetMutableHeaders().getMutableMap();
}
/**
* <code>map&lt;string, string&gt; headers = 7;</code>
*/
public Builder putHeaders(
String key,
String value) {
if (key == null) { throw new NullPointerException(); }
if (value == null) { throw new NullPointerException(); }
internalGetMutableHeaders().getMutableMap()
.put(key, value);
return this;
}
/**
* <code>map&lt;string, string&gt; headers = 7;</code>
*/
public Builder putAllHeaders(
java.util.Map<String, String> values) {
internalGetMutableHeaders().getMutableMap()
.putAll(values);
return this;
}
@Override
public final Builder setUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.setUnknownFields(unknownFields);
}
@Override
public final Builder mergeUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.mergeUnknownFields(unknownFields);
}
// @@protoc_insertion_point(builder_scope:Metadata)
}
// @@protoc_insertion_point(class_scope:Metadata)
private static final Metadata DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new Metadata();
}
public static Metadata getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<Metadata>
PARSER = new com.google.protobuf.AbstractParser<Metadata>() {
@Override
public Metadata parsePartialFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return new Metadata(input, extensionRegistry);
}
};
public static com.google.protobuf.Parser<Metadata> parser() {
return PARSER;
}
@Override
public com.google.protobuf.Parser<Metadata> getParserForType() {
return PARSER;
}
@Override
public Metadata getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}

View File

@ -0,0 +1,76 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.grpc.auto;
public interface MetadataOrBuilder extends
// @@protoc_insertion_point(interface_extends:Metadata)
com.google.protobuf.MessageOrBuilder {
/**
* <code>string type = 3;</code>
*/
String getType();
/**
* <code>string type = 3;</code>
*/
com.google.protobuf.ByteString
getTypeBytes();
/**
* <code>string clientIp = 8;</code>
*/
String getClientIp();
/**
* <code>string clientIp = 8;</code>
*/
com.google.protobuf.ByteString
getClientIpBytes();
/**
* <code>map&lt;string, string&gt; headers = 7;</code>
*/
int getHeadersCount();
/**
* <code>map&lt;string, string&gt; headers = 7;</code>
*/
boolean containsHeaders(
String key);
/**
* Use {@link #getHeadersMap()} instead.
*/
@Deprecated
java.util.Map<String, String>
getHeaders();
/**
* <code>map&lt;string, string&gt; headers = 7;</code>
*/
java.util.Map<String, String>
getHeadersMap();
/**
* <code>map&lt;string, string&gt; headers = 7;</code>
*/
String getHeadersOrDefault(
String key,
String defaultValue);
/**
* <code>map&lt;string, string&gt; headers = 7;</code>
*/
String getHeadersOrThrow(
String key);
}

View File

@ -0,0 +1,97 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.grpc.auto;
public final class NacosGrpcService {
private NacosGrpcService() {}
public static void registerAllExtensions(
com.google.protobuf.ExtensionRegistryLite registry) {
}
public static void registerAllExtensions(
com.google.protobuf.ExtensionRegistry registry) {
registerAllExtensions(
(com.google.protobuf.ExtensionRegistryLite) registry);
}
static final com.google.protobuf.Descriptors.Descriptor
internal_static_Metadata_descriptor;
static final
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internal_static_Metadata_fieldAccessorTable;
static final com.google.protobuf.Descriptors.Descriptor
internal_static_Metadata_HeadersEntry_descriptor;
static final
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internal_static_Metadata_HeadersEntry_fieldAccessorTable;
static final com.google.protobuf.Descriptors.Descriptor
internal_static_Payload_descriptor;
static final
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internal_static_Payload_fieldAccessorTable;
public static com.google.protobuf.Descriptors.FileDescriptor
getDescriptor() {
return descriptor;
}
private static com.google.protobuf.Descriptors.FileDescriptor
descriptor;
static {
String[] descriptorData = {
"\n\030nacos_grpc_service.proto\032\031google/proto" +
"buf/any.proto\032\037google/protobuf/timestamp" +
".proto\"\203\001\n\010Metadata\022\014\n\004type\030\003 \001(\t\022\020\n\010cli" +
"entIp\030\010 \001(\t\022\'\n\007headers\030\007 \003(\0132\026.Metadata." +
"HeadersEntry\032.\n\014HeadersEntry\022\013\n\003key\030\001 \001(" +
"\t\022\r\n\005value\030\002 \001(\t:\0028\001\"J\n\007Payload\022\033\n\010metad" +
"ata\030\002 \001(\0132\t.Metadata\022\"\n\004body\030\003 \001(\0132\024.goo" +
"gle.protobuf.Any28\n\rRequestStream\022\'\n\rreq" +
"uestStream\022\010.Payload\032\010.Payload\"\0000\0012*\n\007Re" +
"quest\022\037\n\007request\022\010.Payload\032\010.Payload\"\0002>" +
"\n\017BiRequestStream\022+\n\017requestBiStream\022\010.P" +
"ayload\032\010.Payload\"\000(\0010\001B#\n\037com.alibaba.na" +
"cos.api.grpc.autoP\001b\006proto3"
};
descriptor = com.google.protobuf.Descriptors.FileDescriptor
.internalBuildGeneratedFileFrom(descriptorData,
new com.google.protobuf.Descriptors.FileDescriptor[] {
com.google.protobuf.AnyProto.getDescriptor(),
com.google.protobuf.TimestampProto.getDescriptor(),
});
internal_static_Metadata_descriptor =
getDescriptor().getMessageTypes().get(0);
internal_static_Metadata_fieldAccessorTable = new
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
internal_static_Metadata_descriptor,
new String[] { "Type", "ClientIp", "Headers", });
internal_static_Metadata_HeadersEntry_descriptor =
internal_static_Metadata_descriptor.getNestedTypes().get(0);
internal_static_Metadata_HeadersEntry_fieldAccessorTable = new
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
internal_static_Metadata_HeadersEntry_descriptor,
new String[] { "Key", "Value", });
internal_static_Payload_descriptor =
getDescriptor().getMessageTypes().get(1);
internal_static_Payload_fieldAccessorTable = new
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
internal_static_Payload_descriptor,
new String[] { "Metadata", "Body", });
com.google.protobuf.AnyProto.getDescriptor();
com.google.protobuf.TimestampProto.getDescriptor();
}
// @@protoc_insertion_point(outer_class_scope)
}

View File

@ -0,0 +1,794 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.grpc.auto;
/**
* Protobuf type {@code Payload}
*/
public final class Payload extends
com.google.protobuf.GeneratedMessageV3 implements
// @@protoc_insertion_point(message_implements:Payload)
PayloadOrBuilder {
private static final long serialVersionUID = 0L;
// Use Payload.newBuilder() to construct.
private Payload(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private Payload() {
}
@Override
@SuppressWarnings({"unused"})
protected Object newInstance(
UnusedPrivateParameter unused) {
return new Payload();
}
@Override
public final com.google.protobuf.UnknownFieldSet
getUnknownFields() {
return this.unknownFields;
}
private Payload(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
this();
if (extensionRegistry == null) {
throw new NullPointerException();
}
com.google.protobuf.UnknownFieldSet.Builder unknownFields =
com.google.protobuf.UnknownFieldSet.newBuilder();
try {
boolean done = false;
while (!done) {
int tag = input.readTag();
switch (tag) {
case 0:
done = true;
break;
case 18: {
Metadata.Builder subBuilder = null;
if (metadata_ != null) {
subBuilder = metadata_.toBuilder();
}
metadata_ = input.readMessage(Metadata.parser(), extensionRegistry);
if (subBuilder != null) {
subBuilder.mergeFrom(metadata_);
metadata_ = subBuilder.buildPartial();
}
break;
}
case 26: {
com.google.protobuf.Any.Builder subBuilder = null;
if (body_ != null) {
subBuilder = body_.toBuilder();
}
body_ = input.readMessage(com.google.protobuf.Any.parser(), extensionRegistry);
if (subBuilder != null) {
subBuilder.mergeFrom(body_);
body_ = subBuilder.buildPartial();
}
break;
}
default: {
if (!parseUnknownField(
input, unknownFields, extensionRegistry, tag)) {
done = true;
}
break;
}
}
}
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
throw e.setUnfinishedMessage(this);
} catch (java.io.IOException e) {
throw new com.google.protobuf.InvalidProtocolBufferException(
e).setUnfinishedMessage(this);
} finally {
this.unknownFields = unknownFields.build();
makeExtensionsImmutable();
}
}
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return NacosGrpcService.internal_static_Payload_descriptor;
}
@Override
protected FieldAccessorTable
internalGetFieldAccessorTable() {
return NacosGrpcService.internal_static_Payload_fieldAccessorTable
.ensureFieldAccessorsInitialized(
Payload.class, Builder.class);
}
public static final int METADATA_FIELD_NUMBER = 2;
private Metadata metadata_;
/**
* <code>.Metadata metadata = 2;</code>
*/
public boolean hasMetadata() {
return metadata_ != null;
}
/**
* <code>.Metadata metadata = 2;</code>
*/
public Metadata getMetadata() {
return metadata_ == null ? Metadata.getDefaultInstance() : metadata_;
}
/**
* <code>.Metadata metadata = 2;</code>
*/
public MetadataOrBuilder getMetadataOrBuilder() {
return getMetadata();
}
public static final int BODY_FIELD_NUMBER = 3;
private com.google.protobuf.Any body_;
/**
* <code>.google.protobuf.Any body = 3;</code>
*/
public boolean hasBody() {
return body_ != null;
}
/**
* <code>.google.protobuf.Any body = 3;</code>
*/
public com.google.protobuf.Any getBody() {
return body_ == null ? com.google.protobuf.Any.getDefaultInstance() : body_;
}
/**
* <code>.google.protobuf.Any body = 3;</code>
*/
public com.google.protobuf.AnyOrBuilder getBodyOrBuilder() {
return getBody();
}
private byte memoizedIsInitialized = -1;
@Override
public final boolean isInitialized() {
byte isInitialized = memoizedIsInitialized;
if (isInitialized == 1) return true;
if (isInitialized == 0) return false;
memoizedIsInitialized = 1;
return true;
}
@Override
public void writeTo(com.google.protobuf.CodedOutputStream output)
throws java.io.IOException {
if (metadata_ != null) {
output.writeMessage(2, getMetadata());
}
if (body_ != null) {
output.writeMessage(3, getBody());
}
unknownFields.writeTo(output);
}
@Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (metadata_ != null) {
size += com.google.protobuf.CodedOutputStream
.computeMessageSize(2, getMetadata());
}
if (body_ != null) {
size += com.google.protobuf.CodedOutputStream
.computeMessageSize(3, getBody());
}
size += unknownFields.getSerializedSize();
memoizedSize = size;
return size;
}
@Override
public boolean equals(final Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof Payload)) {
return super.equals(obj);
}
Payload other = (Payload) obj;
if (hasMetadata() != other.hasMetadata()) return false;
if (hasMetadata()) {
if (!getMetadata()
.equals(other.getMetadata())) return false;
}
if (hasBody() != other.hasBody()) return false;
if (hasBody()) {
if (!getBody()
.equals(other.getBody())) return false;
}
if (!unknownFields.equals(other.unknownFields)) return false;
return true;
}
@Override
public int hashCode() {
if (memoizedHashCode != 0) {
return memoizedHashCode;
}
int hash = 41;
hash = (19 * hash) + getDescriptor().hashCode();
if (hasMetadata()) {
hash = (37 * hash) + METADATA_FIELD_NUMBER;
hash = (53 * hash) + getMetadata().hashCode();
}
if (hasBody()) {
hash = (37 * hash) + BODY_FIELD_NUMBER;
hash = (53 * hash) + getBody().hashCode();
}
hash = (29 * hash) + unknownFields.hashCode();
memoizedHashCode = hash;
return hash;
}
public static Payload parseFrom(
java.nio.ByteBuffer data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static Payload parseFrom(
java.nio.ByteBuffer data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static Payload parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static Payload parseFrom(
com.google.protobuf.ByteString data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static Payload parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static Payload parseFrom(
byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static Payload parseFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static Payload parseFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input, extensionRegistry);
}
public static Payload parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input);
}
public static Payload parseDelimitedFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input, extensionRegistry);
}
public static Payload parseFrom(
com.google.protobuf.CodedInputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static Payload parseFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input, extensionRegistry);
}
@Override
public Builder newBuilderForType() { return newBuilder(); }
public static Builder newBuilder() {
return DEFAULT_INSTANCE.toBuilder();
}
public static Builder newBuilder(Payload prototype) {
return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
}
@Override
public Builder toBuilder() {
return this == DEFAULT_INSTANCE
? new Builder() : new Builder().mergeFrom(this);
}
@Override
protected Builder newBuilderForType(
BuilderParent parent) {
Builder builder = new Builder(parent);
return builder;
}
/**
* Protobuf type {@code Payload}
*/
public static final class Builder extends
com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
// @@protoc_insertion_point(builder_implements:Payload)
PayloadOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return NacosGrpcService.internal_static_Payload_descriptor;
}
@Override
protected FieldAccessorTable
internalGetFieldAccessorTable() {
return NacosGrpcService.internal_static_Payload_fieldAccessorTable
.ensureFieldAccessorsInitialized(
Payload.class, Builder.class);
}
// Construct using com.alibaba.nacos.api.grpc.auto.Payload.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private Builder(
BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessageV3
.alwaysUseFieldBuilders) {
}
}
@Override
public Builder clear() {
super.clear();
if (metadataBuilder_ == null) {
metadata_ = null;
} else {
metadata_ = null;
metadataBuilder_ = null;
}
if (bodyBuilder_ == null) {
body_ = null;
} else {
body_ = null;
bodyBuilder_ = null;
}
return this;
}
@Override
public com.google.protobuf.Descriptors.Descriptor
getDescriptorForType() {
return NacosGrpcService.internal_static_Payload_descriptor;
}
@Override
public Payload getDefaultInstanceForType() {
return Payload.getDefaultInstance();
}
@Override
public Payload build() {
Payload result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@Override
public Payload buildPartial() {
Payload result = new Payload(this);
if (metadataBuilder_ == null) {
result.metadata_ = metadata_;
} else {
result.metadata_ = metadataBuilder_.build();
}
if (bodyBuilder_ == null) {
result.body_ = body_;
} else {
result.body_ = bodyBuilder_.build();
}
onBuilt();
return result;
}
@Override
public Builder clone() {
return super.clone();
}
@Override
public Builder setField(
com.google.protobuf.Descriptors.FieldDescriptor field,
Object value) {
return super.setField(field, value);
}
@Override
public Builder clearField(
com.google.protobuf.Descriptors.FieldDescriptor field) {
return super.clearField(field);
}
@Override
public Builder clearOneof(
com.google.protobuf.Descriptors.OneofDescriptor oneof) {
return super.clearOneof(oneof);
}
@Override
public Builder setRepeatedField(
com.google.protobuf.Descriptors.FieldDescriptor field,
int index, Object value) {
return super.setRepeatedField(field, index, value);
}
@Override
public Builder addRepeatedField(
com.google.protobuf.Descriptors.FieldDescriptor field,
Object value) {
return super.addRepeatedField(field, value);
}
@Override
public Builder mergeFrom(com.google.protobuf.Message other) {
if (other instanceof Payload) {
return mergeFrom((Payload)other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(Payload other) {
if (other == Payload.getDefaultInstance()) return this;
if (other.hasMetadata()) {
mergeMetadata(other.getMetadata());
}
if (other.hasBody()) {
mergeBody(other.getBody());
}
this.mergeUnknownFields(other.unknownFields);
onChanged();
return this;
}
@Override
public final boolean isInitialized() {
return true;
}
@Override
public Builder mergeFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
Payload parsedMessage = null;
try {
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
parsedMessage = (Payload) e.getUnfinishedMessage();
throw e.unwrapIOException();
} finally {
if (parsedMessage != null) {
mergeFrom(parsedMessage);
}
}
return this;
}
private Metadata metadata_;
private com.google.protobuf.SingleFieldBuilderV3<
Metadata, Metadata.Builder, MetadataOrBuilder> metadataBuilder_;
/**
* <code>.Metadata metadata = 2;</code>
*/
public boolean hasMetadata() {
return metadataBuilder_ != null || metadata_ != null;
}
/**
* <code>.Metadata metadata = 2;</code>
*/
public Metadata getMetadata() {
if (metadataBuilder_ == null) {
return metadata_ == null ? Metadata.getDefaultInstance() : metadata_;
} else {
return metadataBuilder_.getMessage();
}
}
/**
* <code>.Metadata metadata = 2;</code>
*/
public Builder setMetadata(Metadata value) {
if (metadataBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
metadata_ = value;
onChanged();
} else {
metadataBuilder_.setMessage(value);
}
return this;
}
/**
* <code>.Metadata metadata = 2;</code>
*/
public Builder setMetadata(
Metadata.Builder builderForValue) {
if (metadataBuilder_ == null) {
metadata_ = builderForValue.build();
onChanged();
} else {
metadataBuilder_.setMessage(builderForValue.build());
}
return this;
}
/**
* <code>.Metadata metadata = 2;</code>
*/
public Builder mergeMetadata(Metadata value) {
if (metadataBuilder_ == null) {
if (metadata_ != null) {
metadata_ =
Metadata.newBuilder(metadata_).mergeFrom(value).buildPartial();
} else {
metadata_ = value;
}
onChanged();
} else {
metadataBuilder_.mergeFrom(value);
}
return this;
}
/**
* <code>.Metadata metadata = 2;</code>
*/
public Builder clearMetadata() {
if (metadataBuilder_ == null) {
metadata_ = null;
onChanged();
} else {
metadata_ = null;
metadataBuilder_ = null;
}
return this;
}
/**
* <code>.Metadata metadata = 2;</code>
*/
public Metadata.Builder getMetadataBuilder() {
onChanged();
return getMetadataFieldBuilder().getBuilder();
}
/**
* <code>.Metadata metadata = 2;</code>
*/
public MetadataOrBuilder getMetadataOrBuilder() {
if (metadataBuilder_ != null) {
return metadataBuilder_.getMessageOrBuilder();
} else {
return metadata_ == null ?
Metadata.getDefaultInstance() : metadata_;
}
}
/**
* <code>.Metadata metadata = 2;</code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
Metadata, Metadata.Builder, MetadataOrBuilder>
getMetadataFieldBuilder() {
if (metadataBuilder_ == null) {
metadataBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
Metadata, Metadata.Builder, MetadataOrBuilder>(
getMetadata(),
getParentForChildren(),
isClean());
metadata_ = null;
}
return metadataBuilder_;
}
private com.google.protobuf.Any body_;
private com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder> bodyBuilder_;
/**
* <code>.google.protobuf.Any body = 3;</code>
*/
public boolean hasBody() {
return bodyBuilder_ != null || body_ != null;
}
/**
* <code>.google.protobuf.Any body = 3;</code>
*/
public com.google.protobuf.Any getBody() {
if (bodyBuilder_ == null) {
return body_ == null ? com.google.protobuf.Any.getDefaultInstance() : body_;
} else {
return bodyBuilder_.getMessage();
}
}
/**
* <code>.google.protobuf.Any body = 3;</code>
*/
public Builder setBody(com.google.protobuf.Any value) {
if (bodyBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
body_ = value;
onChanged();
} else {
bodyBuilder_.setMessage(value);
}
return this;
}
/**
* <code>.google.protobuf.Any body = 3;</code>
*/
public Builder setBody(
com.google.protobuf.Any.Builder builderForValue) {
if (bodyBuilder_ == null) {
body_ = builderForValue.build();
onChanged();
} else {
bodyBuilder_.setMessage(builderForValue.build());
}
return this;
}
/**
* <code>.google.protobuf.Any body = 3;</code>
*/
public Builder mergeBody(com.google.protobuf.Any value) {
if (bodyBuilder_ == null) {
if (body_ != null) {
body_ =
com.google.protobuf.Any.newBuilder(body_).mergeFrom(value).buildPartial();
} else {
body_ = value;
}
onChanged();
} else {
bodyBuilder_.mergeFrom(value);
}
return this;
}
/**
* <code>.google.protobuf.Any body = 3;</code>
*/
public Builder clearBody() {
if (bodyBuilder_ == null) {
body_ = null;
onChanged();
} else {
body_ = null;
bodyBuilder_ = null;
}
return this;
}
/**
* <code>.google.protobuf.Any body = 3;</code>
*/
public com.google.protobuf.Any.Builder getBodyBuilder() {
onChanged();
return getBodyFieldBuilder().getBuilder();
}
/**
* <code>.google.protobuf.Any body = 3;</code>
*/
public com.google.protobuf.AnyOrBuilder getBodyOrBuilder() {
if (bodyBuilder_ != null) {
return bodyBuilder_.getMessageOrBuilder();
} else {
return body_ == null ?
com.google.protobuf.Any.getDefaultInstance() : body_;
}
}
/**
* <code>.google.protobuf.Any body = 3;</code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder>
getBodyFieldBuilder() {
if (bodyBuilder_ == null) {
bodyBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder>(
getBody(),
getParentForChildren(),
isClean());
body_ = null;
}
return bodyBuilder_;
}
@Override
public final Builder setUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.setUnknownFields(unknownFields);
}
@Override
public final Builder mergeUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.mergeUnknownFields(unknownFields);
}
// @@protoc_insertion_point(builder_scope:Payload)
}
// @@protoc_insertion_point(class_scope:Payload)
private static final Payload DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new Payload();
}
public static Payload getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<Payload>
PARSER = new com.google.protobuf.AbstractParser<Payload>() {
@Override
public Payload parsePartialFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return new Payload(input, extensionRegistry);
}
};
public static com.google.protobuf.Parser<Payload> parser() {
return PARSER;
}
@Override
public com.google.protobuf.Parser<Payload> getParserForType() {
return PARSER;
}
@Override
public Payload getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}

View File

@ -0,0 +1,48 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.grpc.auto;
public interface PayloadOrBuilder extends
// @@protoc_insertion_point(interface_extends:Payload)
com.google.protobuf.MessageOrBuilder {
/**
* <code>.Metadata metadata = 2;</code>
*/
boolean hasMetadata();
/**
* <code>.Metadata metadata = 2;</code>
*/
Metadata getMetadata();
/**
* <code>.Metadata metadata = 2;</code>
*/
MetadataOrBuilder getMetadataOrBuilder();
/**
* <code>.google.protobuf.Any body = 3;</code>
*/
boolean hasBody();
/**
* <code>.google.protobuf.Any body = 3;</code>
*/
com.google.protobuf.Any getBody();
/**
* <code>.google.protobuf.Any body = 3;</code>
*/
com.google.protobuf.AnyOrBuilder getBodyOrBuilder();
}

View File

@ -0,0 +1,308 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.grpc.auto;
import static io.grpc.MethodDescriptor.generateFullMethodName;
import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall;
import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
import static io.grpc.stub.ClientCalls.asyncUnaryCall;
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
import static io.grpc.stub.ClientCalls.blockingUnaryCall;
import static io.grpc.stub.ClientCalls.futureUnaryCall;
import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
import static io.grpc.stub.ServerCalls.asyncUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
/**
*/
@javax.annotation.Generated(
value = "by gRPC proto compiler (version 1.14.0)",
comments = "Source: nacos_grpc_service.proto")
public final class RequestGrpc {
private RequestGrpc() {}
public static final String SERVICE_NAME = "Request";
// Static method descriptors that strictly reflect the proto.
private static volatile io.grpc.MethodDescriptor<com.alibaba.nacos.api.grpc.auto.Payload,
com.alibaba.nacos.api.grpc.auto.Payload> getRequestMethod;
@io.grpc.stub.annotations.RpcMethod(
fullMethodName = SERVICE_NAME + '/' + "request",
requestType = com.alibaba.nacos.api.grpc.auto.Payload.class,
responseType = com.alibaba.nacos.api.grpc.auto.Payload.class,
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
public static io.grpc.MethodDescriptor<com.alibaba.nacos.api.grpc.auto.Payload,
com.alibaba.nacos.api.grpc.auto.Payload> getRequestMethod() {
io.grpc.MethodDescriptor<com.alibaba.nacos.api.grpc.auto.Payload, com.alibaba.nacos.api.grpc.auto.Payload> getRequestMethod;
if ((getRequestMethod = RequestGrpc.getRequestMethod) == null) {
synchronized (RequestGrpc.class) {
if ((getRequestMethod = RequestGrpc.getRequestMethod) == null) {
RequestGrpc.getRequestMethod = getRequestMethod =
io.grpc.MethodDescriptor.<com.alibaba.nacos.api.grpc.auto.Payload, com.alibaba.nacos.api.grpc.auto.Payload>newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
.setFullMethodName(generateFullMethodName(
"Request", "request"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
com.alibaba.nacos.api.grpc.auto.Payload.getDefaultInstance()))
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
com.alibaba.nacos.api.grpc.auto.Payload.getDefaultInstance()))
.setSchemaDescriptor(new RequestMethodDescriptorSupplier("request"))
.build();
}
}
}
return getRequestMethod;
}
/**
* Creates a new async stub that supports all call types for the service
*/
public static RequestStub newStub(io.grpc.Channel channel) {
return new RequestStub(channel);
}
/**
* Creates a new blocking-style stub that supports unary and streaming output calls on the service
*/
public static RequestBlockingStub newBlockingStub(
io.grpc.Channel channel) {
return new RequestBlockingStub(channel);
}
/**
* Creates a new ListenableFuture-style stub that supports unary calls on the service
*/
public static RequestFutureStub newFutureStub(
io.grpc.Channel channel) {
return new RequestFutureStub(channel);
}
/**
*/
public static abstract class RequestImplBase implements io.grpc.BindableService {
/**
* <pre>
* Sends a commonRequest
* </pre>
*/
public void request(com.alibaba.nacos.api.grpc.auto.Payload request,
io.grpc.stub.StreamObserver<com.alibaba.nacos.api.grpc.auto.Payload> responseObserver) {
asyncUnimplementedUnaryCall(getRequestMethod(), responseObserver);
}
@Override public final io.grpc.ServerServiceDefinition bindService() {
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
.addMethod(
getRequestMethod(),
asyncUnaryCall(
new MethodHandlers<
com.alibaba.nacos.api.grpc.auto.Payload,
com.alibaba.nacos.api.grpc.auto.Payload>(
this, METHODID_REQUEST)))
.build();
}
}
/**
*/
public static final class RequestStub extends io.grpc.stub.AbstractStub<RequestStub> {
private RequestStub(io.grpc.Channel channel) {
super(channel);
}
private RequestStub(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
super(channel, callOptions);
}
@Override
protected RequestStub build(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
return new RequestStub(channel, callOptions);
}
/**
* <pre>
* Sends a commonRequest
* </pre>
*/
public void request(com.alibaba.nacos.api.grpc.auto.Payload request,
io.grpc.stub.StreamObserver<com.alibaba.nacos.api.grpc.auto.Payload> responseObserver) {
asyncUnaryCall(
getChannel().newCall(getRequestMethod(), getCallOptions()), request, responseObserver);
}
}
/**
*/
public static final class RequestBlockingStub extends io.grpc.stub.AbstractStub<RequestBlockingStub> {
private RequestBlockingStub(io.grpc.Channel channel) {
super(channel);
}
private RequestBlockingStub(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
super(channel, callOptions);
}
@Override
protected RequestBlockingStub build(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
return new RequestBlockingStub(channel, callOptions);
}
/**
* <pre>
* Sends a commonRequest
* </pre>
*/
public com.alibaba.nacos.api.grpc.auto.Payload request(com.alibaba.nacos.api.grpc.auto.Payload request) {
return blockingUnaryCall(
getChannel(), getRequestMethod(), getCallOptions(), request);
}
}
/**
*/
public static final class RequestFutureStub extends io.grpc.stub.AbstractStub<RequestFutureStub> {
private RequestFutureStub(io.grpc.Channel channel) {
super(channel);
}
private RequestFutureStub(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
super(channel, callOptions);
}
@Override
protected RequestFutureStub build(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
return new RequestFutureStub(channel, callOptions);
}
/**
* <pre>
* Sends a commonRequest
* </pre>
*/
public com.google.common.util.concurrent.ListenableFuture<com.alibaba.nacos.api.grpc.auto.Payload> request(
com.alibaba.nacos.api.grpc.auto.Payload request) {
return futureUnaryCall(
getChannel().newCall(getRequestMethod(), getCallOptions()), request);
}
}
private static final int METHODID_REQUEST = 0;
private static final class MethodHandlers<Req, Resp> implements
io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
private final RequestImplBase serviceImpl;
private final int methodId;
MethodHandlers(RequestImplBase serviceImpl, int methodId) {
this.serviceImpl = serviceImpl;
this.methodId = methodId;
}
@Override
@SuppressWarnings("unchecked")
public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
switch (methodId) {
case METHODID_REQUEST:
serviceImpl.request((com.alibaba.nacos.api.grpc.auto.Payload) request,
(io.grpc.stub.StreamObserver<com.alibaba.nacos.api.grpc.auto.Payload>) responseObserver);
break;
default:
throw new AssertionError();
}
}
@Override
@SuppressWarnings("unchecked")
public io.grpc.stub.StreamObserver<Req> invoke(
io.grpc.stub.StreamObserver<Resp> responseObserver) {
switch (methodId) {
default:
throw new AssertionError();
}
}
}
private static abstract class RequestBaseDescriptorSupplier
implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier {
RequestBaseDescriptorSupplier() {}
@Override
public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
return com.alibaba.nacos.api.grpc.auto.NacosGrpcService.getDescriptor();
}
@Override
public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() {
return getFileDescriptor().findServiceByName("Request");
}
}
private static final class RequestFileDescriptorSupplier
extends RequestBaseDescriptorSupplier {
RequestFileDescriptorSupplier() {}
}
private static final class RequestMethodDescriptorSupplier
extends RequestBaseDescriptorSupplier
implements io.grpc.protobuf.ProtoMethodDescriptorSupplier {
private final String methodName;
RequestMethodDescriptorSupplier(String methodName) {
this.methodName = methodName;
}
@Override
public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() {
return getServiceDescriptor().findMethodByName(methodName);
}
}
private static volatile io.grpc.ServiceDescriptor serviceDescriptor;
public static io.grpc.ServiceDescriptor getServiceDescriptor() {
io.grpc.ServiceDescriptor result = serviceDescriptor;
if (result == null) {
synchronized (RequestGrpc.class) {
result = serviceDescriptor;
if (result == null) {
serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
.setSchemaDescriptor(new RequestFileDescriptorSupplier())
.addMethod(getRequestMethod())
.build();
}
}
}
return result;
}
}

View File

@ -0,0 +1,298 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.grpc.auto;
import static io.grpc.MethodDescriptor.generateFullMethodName;
import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall;
import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
import static io.grpc.stub.ClientCalls.asyncUnaryCall;
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
import static io.grpc.stub.ClientCalls.blockingUnaryCall;
import static io.grpc.stub.ClientCalls.futureUnaryCall;
import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
import static io.grpc.stub.ServerCalls.asyncUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
/**
*/
@javax.annotation.Generated(
value = "by gRPC proto compiler (version 1.14.0)",
comments = "Source: nacos_grpc_service.proto")
public final class RequestStreamGrpc {
private RequestStreamGrpc() {}
public static final String SERVICE_NAME = "RequestStream";
// Static method descriptors that strictly reflect the proto.
private static volatile io.grpc.MethodDescriptor<com.alibaba.nacos.api.grpc.auto.Payload,
com.alibaba.nacos.api.grpc.auto.Payload> getRequestStreamMethod;
@io.grpc.stub.annotations.RpcMethod(
fullMethodName = SERVICE_NAME + '/' + "requestStream",
requestType = com.alibaba.nacos.api.grpc.auto.Payload.class,
responseType = com.alibaba.nacos.api.grpc.auto.Payload.class,
methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING)
public static io.grpc.MethodDescriptor<com.alibaba.nacos.api.grpc.auto.Payload,
com.alibaba.nacos.api.grpc.auto.Payload> getRequestStreamMethod() {
io.grpc.MethodDescriptor<com.alibaba.nacos.api.grpc.auto.Payload, com.alibaba.nacos.api.grpc.auto.Payload> getRequestStreamMethod;
if ((getRequestStreamMethod = RequestStreamGrpc.getRequestStreamMethod) == null) {
synchronized (RequestStreamGrpc.class) {
if ((getRequestStreamMethod = RequestStreamGrpc.getRequestStreamMethod) == null) {
RequestStreamGrpc.getRequestStreamMethod = getRequestStreamMethod =
io.grpc.MethodDescriptor.<com.alibaba.nacos.api.grpc.auto.Payload, com.alibaba.nacos.api.grpc.auto.Payload>newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING)
.setFullMethodName(generateFullMethodName(
"RequestStream", "requestStream"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
com.alibaba.nacos.api.grpc.auto.Payload.getDefaultInstance()))
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
com.alibaba.nacos.api.grpc.auto.Payload.getDefaultInstance()))
.setSchemaDescriptor(new RequestStreamMethodDescriptorSupplier("requestStream"))
.build();
}
}
}
return getRequestStreamMethod;
}
/**
* Creates a new async stub that supports all call types for the service
*/
public static RequestStreamStub newStub(io.grpc.Channel channel) {
return new RequestStreamStub(channel);
}
/**
* Creates a new blocking-style stub that supports unary and streaming output calls on the service
*/
public static RequestStreamBlockingStub newBlockingStub(
io.grpc.Channel channel) {
return new RequestStreamBlockingStub(channel);
}
/**
* Creates a new ListenableFuture-style stub that supports unary calls on the service
*/
public static RequestStreamFutureStub newFutureStub(
io.grpc.Channel channel) {
return new RequestStreamFutureStub(channel);
}
/**
*/
public static abstract class RequestStreamImplBase implements io.grpc.BindableService {
/**
* <pre>
* build a streamRequest
* </pre>
*/
public void requestStream(com.alibaba.nacos.api.grpc.auto.Payload request,
io.grpc.stub.StreamObserver<com.alibaba.nacos.api.grpc.auto.Payload> responseObserver) {
asyncUnimplementedUnaryCall(getRequestStreamMethod(), responseObserver);
}
@Override public final io.grpc.ServerServiceDefinition bindService() {
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
.addMethod(
getRequestStreamMethod(),
asyncServerStreamingCall(
new MethodHandlers<
com.alibaba.nacos.api.grpc.auto.Payload,
com.alibaba.nacos.api.grpc.auto.Payload>(
this, METHODID_REQUEST_STREAM)))
.build();
}
}
/**
*/
public static final class RequestStreamStub extends io.grpc.stub.AbstractStub<RequestStreamStub> {
private RequestStreamStub(io.grpc.Channel channel) {
super(channel);
}
private RequestStreamStub(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
super(channel, callOptions);
}
@Override
protected RequestStreamStub build(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
return new RequestStreamStub(channel, callOptions);
}
/**
* <pre>
* build a streamRequest
* </pre>
*/
public void requestStream(com.alibaba.nacos.api.grpc.auto.Payload request,
io.grpc.stub.StreamObserver<com.alibaba.nacos.api.grpc.auto.Payload> responseObserver) {
asyncServerStreamingCall(
getChannel().newCall(getRequestStreamMethod(), getCallOptions()), request, responseObserver);
}
}
/**
*/
public static final class RequestStreamBlockingStub extends io.grpc.stub.AbstractStub<RequestStreamBlockingStub> {
private RequestStreamBlockingStub(io.grpc.Channel channel) {
super(channel);
}
private RequestStreamBlockingStub(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
super(channel, callOptions);
}
@Override
protected RequestStreamBlockingStub build(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
return new RequestStreamBlockingStub(channel, callOptions);
}
/**
* <pre>
* build a streamRequest
* </pre>
*/
public java.util.Iterator<com.alibaba.nacos.api.grpc.auto.Payload> requestStream(
com.alibaba.nacos.api.grpc.auto.Payload request) {
return blockingServerStreamingCall(
getChannel(), getRequestStreamMethod(), getCallOptions(), request);
}
}
/**
*/
public static final class RequestStreamFutureStub extends io.grpc.stub.AbstractStub<RequestStreamFutureStub> {
private RequestStreamFutureStub(io.grpc.Channel channel) {
super(channel);
}
private RequestStreamFutureStub(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
super(channel, callOptions);
}
@Override
protected RequestStreamFutureStub build(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
return new RequestStreamFutureStub(channel, callOptions);
}
}
private static final int METHODID_REQUEST_STREAM = 0;
private static final class MethodHandlers<Req, Resp> implements
io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
private final RequestStreamImplBase serviceImpl;
private final int methodId;
MethodHandlers(RequestStreamImplBase serviceImpl, int methodId) {
this.serviceImpl = serviceImpl;
this.methodId = methodId;
}
@Override
@SuppressWarnings("unchecked")
public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
switch (methodId) {
case METHODID_REQUEST_STREAM:
serviceImpl.requestStream((com.alibaba.nacos.api.grpc.auto.Payload) request,
(io.grpc.stub.StreamObserver<com.alibaba.nacos.api.grpc.auto.Payload>) responseObserver);
break;
default:
throw new AssertionError();
}
}
@Override
@SuppressWarnings("unchecked")
public io.grpc.stub.StreamObserver<Req> invoke(
io.grpc.stub.StreamObserver<Resp> responseObserver) {
switch (methodId) {
default:
throw new AssertionError();
}
}
}
private static abstract class RequestStreamBaseDescriptorSupplier
implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier {
RequestStreamBaseDescriptorSupplier() {}
@Override
public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
return com.alibaba.nacos.api.grpc.auto.NacosGrpcService.getDescriptor();
}
@Override
public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() {
return getFileDescriptor().findServiceByName("RequestStream");
}
}
private static final class RequestStreamFileDescriptorSupplier
extends RequestStreamBaseDescriptorSupplier {
RequestStreamFileDescriptorSupplier() {}
}
private static final class RequestStreamMethodDescriptorSupplier
extends RequestStreamBaseDescriptorSupplier
implements io.grpc.protobuf.ProtoMethodDescriptorSupplier {
private final String methodName;
RequestStreamMethodDescriptorSupplier(String methodName) {
this.methodName = methodName;
}
@Override
public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() {
return getServiceDescriptor().findMethodByName(methodName);
}
}
private static volatile io.grpc.ServiceDescriptor serviceDescriptor;
public static io.grpc.ServiceDescriptor getServiceDescriptor() {
io.grpc.ServiceDescriptor result = serviceDescriptor;
if (result == null) {
synchronized (RequestStreamGrpc.class) {
result = serviceDescriptor;
if (result == null) {
serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
.setSchemaDescriptor(new RequestStreamFileDescriptorSupplier())
.addMethod(getRequestStreamMethod())
.build();
}
}
}
return result;
}
}

View File

@ -0,0 +1,46 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.naming;
/**
* naming abilities of nacos client.
*
* @author liuzunfei
* @version $Id: ClientNamingAbility.java, v 0.1 2021年01月24日 00:09 AM liuzunfei Exp $
*/
public class ClientNamingAbility {
private boolean supportDeltaPush;
private boolean supportRemoteMetric;
public boolean isSupportDeltaPush() {
return supportDeltaPush;
}
public void setSupportDeltaPush(boolean supportDeltaPush) {
this.supportDeltaPush = supportDeltaPush;
}
public boolean isSupportRemoteMetric() {
return supportRemoteMetric;
}
public void setSupportRemoteMetric(boolean supportRemoteMetric) {
this.supportRemoteMetric = supportRemoteMetric;
}
}

View File

@ -35,4 +35,6 @@ public class CommonParams {
public static final String GROUP_NAME = "groupName";
public static final String LIGHT_BEAT_ENABLED = "lightBeatEnabled";
public static final String NAMING_REQUEST_TIMEOUT = "namingRequestTimeout";
}

View File

@ -33,4 +33,9 @@ public class NamingResponseCode extends ResponseCode {
*/
public static final int RESOURCE_NOT_FOUND = 20404;
/**
* Stop or no need to retry.
*/
public static final int NO_NEED_RETRY = 21600;
}

View File

@ -0,0 +1,61 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.naming;
import java.io.Serializable;
import java.util.Objects;
/**
* naming abilities of nacos server.
*
* @author liuzunfei
* @version $Id: ServerNamingAbility.java, v 0.1 2021年01月24日 00:09 AM liuzunfei Exp $
*/
public class ServerNamingAbility implements Serializable {
private static final long serialVersionUID = 8308895444341445512L;
/**
* Nacos server can use SOFA-Jraft to handle persist service and metadata.
*/
private boolean supportJraft;
public boolean isSupportJraft() {
return supportJraft;
}
public void setSupportJraft(boolean supportJraft) {
this.supportJraft = supportJraft;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof ServerNamingAbility)) {
return false;
}
ServerNamingAbility that = (ServerNamingAbility) o;
return supportJraft == that.supportJraft;
}
@Override
public int hashCode() {
return Objects.hash(supportJraft);
}
}

View File

@ -57,6 +57,8 @@ public class ServiceInfo {
private volatile boolean allIPs = false;
private volatile boolean reachProtectionThreshold = false;
public ServiceInfo() {
}
@ -109,6 +111,18 @@ public class ServiceInfo {
this.hosts = hosts;
}
public void addHost(Instance host) {
hosts.add(host);
}
public void addAllHosts(List<? extends Instance> hosts) {
this.hosts.addAll(hosts);
}
public List<Instance> getHosts() {
return new ArrayList<Instance>(hosts);
}
public boolean isValid() {
return hosts != null;
}
@ -153,10 +167,6 @@ public class ServiceInfo {
this.cacheMillis = cacheMillis;
}
public List<Instance> getHosts() {
return new ArrayList<Instance>(hosts);
}
/**
* Judge whether service info is validate.
*
@ -275,6 +285,14 @@ public class ServiceInfo {
return str1 == null ? str2 == null : str1.equals(str2);
}
public boolean isReachProtectionThreshold() {
return reachProtectionThreshold;
}
public void setReachProtectionThreshold(boolean reachProtectionThreshold) {
this.reachProtectionThreshold = reachProtectionThreshold;
}
private static final String EMPTY = "";
private static final String ALL_IPS = "000--00-ALL_IPS--00--000";

View File

@ -67,7 +67,9 @@ public abstract class AbstractHealthChecker implements Cloneable, Serializable {
public static class None extends AbstractHealthChecker {
public static final String TYPE = "NONE";
private static final long serialVersionUID = -760631831097384737L;
public None() {
super(TYPE);
}

View File

@ -35,6 +35,8 @@ public class Http extends AbstractHealthChecker {
public static final String TYPE = "HTTP";
private static final long serialVersionUID = 551826315222362349L;
private String path = "";
private String headers = "";

View File

@ -29,6 +29,8 @@ public class Mysql extends AbstractHealthChecker {
public static final String TYPE = "MYSQL";
private static final long serialVersionUID = 7928108094599401491L;
private String user;
private String pwd;

View File

@ -28,6 +28,8 @@ public class Tcp extends AbstractHealthChecker {
public static final String TYPE = "TCP";
private static final long serialVersionUID = -9116042038157496294L;
public Tcp() {
super(TYPE);
}

View File

@ -0,0 +1,42 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.naming.remote;
/**
* Retain all naming module request type constants.
*
* @author liuzunfei
* @author xiweng.yy
*/
public class NamingRemoteConstants {
public static final String REGISTER_INSTANCE = "registerInstance";
public static final String DE_REGISTER_INSTANCE = "deregisterInstance";
public static final String QUERY_SERVICE = "queryService";
public static final String SUBSCRIBE_SERVICE = "subscribeService";
public static final String NOTIFY_SUBSCRIBER = "notifySubscriber";
public static final String LIST_SERVICE = "listService";
public static final String FORWARD_INSTANCE = "forwardInstance";
public static final String FORWARD_HEART_BEAT = "forwardHeartBeat";
}

View File

@ -0,0 +1,71 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.naming.remote.request;
import com.alibaba.nacos.api.remote.request.Request;
/**
* Uniform remote request of naming module.
*
* @author liuzunfei
*/
public abstract class AbstractNamingRequest extends Request {
private String namespace;
private String serviceName;
private String groupName;
public AbstractNamingRequest() {
}
public AbstractNamingRequest(String namespace, String serviceName, String groupName) {
this.namespace = namespace;
this.serviceName = serviceName;
this.groupName = groupName;
}
@Override
public String getModule() {
return "naming";
}
public String getNamespace() {
return namespace;
}
public void setNamespace(String namespace) {
this.namespace = namespace;
}
public String getServiceName() {
return serviceName;
}
public void setServiceName(String serviceName) {
this.serviceName = serviceName;
}
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
}

View File

@ -14,26 +14,38 @@
* limitations under the License.
*/
package com.alibaba.nacos.naming.healthcheck.events;
package com.alibaba.nacos.api.naming.remote.request;
import com.alibaba.nacos.naming.core.Instance;
import org.springframework.context.ApplicationEvent;
import com.alibaba.nacos.api.naming.pojo.Instance;
/**
* Instance heart beat timeout event.
* Nacos instances request.
*
* @author pbting
* @date 2019-05-28 8:29 PM
* @author xiweng.yy
*/
public class InstanceHeartbeatTimeoutEvent extends ApplicationEvent {
public class InstanceRequest extends AbstractNamingRequest {
private String type;
private Instance instance;
public InstanceHeartbeatTimeoutEvent(Object source, Instance instance) {
super(source);
public InstanceRequest() {
}
public InstanceRequest(String namespace, String serviceName, String groupName, String type, Instance instance) {
super(namespace, serviceName, groupName);
this.type = type;
this.instance = instance;
}
public void setType(String type) {
this.type = type;
}
public String getType() {
return this.type;
}
public void setInstance(Instance instance) {
this.instance = instance;
}

View File

@ -0,0 +1,96 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.naming.remote.request;
import com.alibaba.nacos.api.naming.pojo.ServiceInfo;
import com.alibaba.nacos.api.remote.request.ServerRequest;
/**
* Notify subscriber response.
*
* @author xiweng.yy
*/
public class NotifySubscriberRequest extends ServerRequest {
private String namespace;
private String serviceName;
private String groupName;
private ServiceInfo serviceInfo;
public NotifySubscriberRequest() {
}
@Override
public String getModule() {
return "naming";
}
private NotifySubscriberRequest(ServiceInfo serviceInfo, String message) {
this.serviceInfo = serviceInfo;
}
public static NotifySubscriberRequest buildSuccessResponse(ServiceInfo serviceInfo) {
return new NotifySubscriberRequest(serviceInfo, "success");
}
/**
* Build fail response.
*
* @param message error message
* @return fail response
*/
public static NotifySubscriberRequest buildFailResponse(String message) {
NotifySubscriberRequest result = new NotifySubscriberRequest();
return result;
}
public ServiceInfo getServiceInfo() {
return serviceInfo;
}
public void setServiceInfo(ServiceInfo serviceInfo) {
this.serviceInfo = serviceInfo;
}
public String getNamespace() {
return namespace;
}
public void setNamespace(String namespace) {
this.namespace = namespace;
}
public String getServiceName() {
return serviceName;
}
public void setServiceName(String serviceName) {
this.serviceName = serviceName;
}
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
}

View File

@ -0,0 +1,64 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.naming.remote.request;
/**
* Service list request.
*
* @author xiweng.yy
*/
public class ServiceListRequest extends AbstractNamingRequest {
private int pageNo;
private int pageSize;
private String selector;
public ServiceListRequest() {
}
public ServiceListRequest(String namespace, String groupName, int pageNo, int pageSize) {
super(namespace, "", groupName);
this.pageNo = pageNo;
this.pageSize = pageSize;
}
public int getPageNo() {
return pageNo;
}
public void setPageNo(int pageNo) {
this.pageNo = pageNo;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public String getSelector() {
return selector;
}
public void setSelector(String selector) {
this.selector = selector;
}
}

View File

@ -0,0 +1,62 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.naming.remote.request;
/**
* Nacos naming query request.
*
* @author xiweng.yy
*/
public class ServiceQueryRequest extends AbstractNamingRequest {
private String cluster;
private boolean healthyOnly;
private int udpPort;
public ServiceQueryRequest() {
}
public ServiceQueryRequest(String namespace, String serviceName, String groupName) {
super(namespace, serviceName, groupName);
}
public String getCluster() {
return cluster;
}
public void setCluster(String cluster) {
this.cluster = cluster;
}
public boolean isHealthyOnly() {
return healthyOnly;
}
public void setHealthyOnly(boolean healthyOnly) {
this.healthyOnly = healthyOnly;
}
public int getUdpPort() {
return udpPort;
}
public void setUdpPort(int udpPort) {
this.udpPort = udpPort;
}
}

View File

@ -0,0 +1,55 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.naming.remote.request;
/**
* Nacos naming subscribe service request.
*
* @author xiweng.yy
*/
public class SubscribeServiceRequest extends AbstractNamingRequest {
private boolean subscribe;
private String clusters;
public SubscribeServiceRequest() {
}
public SubscribeServiceRequest(String namespace, String groupName, String serviceName, String clusters,
boolean subscribe) {
super(namespace, serviceName, groupName);
this.clusters = clusters;
this.subscribe = subscribe;
}
public String getClusters() {
return clusters;
}
public void setClusters(String clusters) {
this.clusters = clusters;
}
public boolean isSubscribe() {
return subscribe;
}
public void setSubscribe(boolean subscribe) {
this.subscribe = subscribe;
}
}

View File

@ -0,0 +1,41 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.naming.remote.response;
import com.alibaba.nacos.api.remote.response.Response;
/**
* Instance response.
*
* @author xiweng.yy
*/
public class InstanceResponse extends Response {
private String type;
public InstanceResponse() {
}
public InstanceResponse(String type) {
this.type = type;
}
public void setType(String type) {
this.type = type;
}
}

View File

@ -0,0 +1,28 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.naming.remote.response;
import com.alibaba.nacos.api.remote.response.Response;
/**
* response for notify service subscribe.
* @author liuzunfei
* @version $Id: NotifySubscriberResponse.java, v 0.1 2020年08月06日 5:28 PM liuzunfei Exp $
*/
public class NotifySubscriberResponse extends Response {
}

View File

@ -0,0 +1,69 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.naming.remote.response;
import com.alibaba.nacos.api.naming.pojo.ServiceInfo;
import com.alibaba.nacos.api.remote.response.Response;
import com.alibaba.nacos.api.remote.response.ResponseCode;
/**
* Nacos naming query request.
*
* @author xiweng.yy
*/
public class QueryServiceResponse extends Response {
private ServiceInfo serviceInfo;
public QueryServiceResponse() {
}
private QueryServiceResponse(ServiceInfo serviceInfo) {
this.serviceInfo = serviceInfo;
}
/**
* Build Success response.
*
* @param serviceInfo service info
* @return service query response
*/
public static QueryServiceResponse buildSuccessResponse(ServiceInfo serviceInfo) {
return new QueryServiceResponse(serviceInfo);
}
/**
* Build fail response.
*
* @param message message
* @return service query response
*/
public static QueryServiceResponse buildFailResponse(String message) {
QueryServiceResponse queryServiceResponse = new QueryServiceResponse();
queryServiceResponse.setResultCode(ResponseCode.FAIL.getCode());
queryServiceResponse.setMessage(message);
return queryServiceResponse;
}
public ServiceInfo getServiceInfo() {
return serviceInfo;
}
public void setServiceInfo(ServiceInfo serviceInfo) {
this.serviceInfo = serviceInfo;
}
}

View File

@ -0,0 +1,74 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.naming.remote.response;
import com.alibaba.nacos.api.remote.response.Response;
import com.alibaba.nacos.api.remote.response.ResponseCode;
import java.util.List;
/**
* Service list response.
*
* @author xiweng.yy
*/
public class ServiceListResponse extends Response {
private int count;
private List<String> serviceNames;
public ServiceListResponse(){
}
private ServiceListResponse(int count, List<String> serviceNames, String message) {
this.count = count;
this.serviceNames = serviceNames;
}
public static ServiceListResponse buildSuccessResponse(int count, List<String> serviceNames) {
return new ServiceListResponse(count, serviceNames, "success");
}
/**
* Build fail response.
*
* @param message error message
* @return fail response
*/
public static ServiceListResponse buildFailResponse(String message) {
ServiceListResponse result = new ServiceListResponse();
result.setErrorInfo(ResponseCode.FAIL.getCode(), message);
return result;
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
public List<String> getServiceNames() {
return serviceNames;
}
public void setServiceNames(List<String> serviceNames) {
this.serviceNames = serviceNames;
}
}

View File

@ -0,0 +1,48 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.naming.remote.response;
import com.alibaba.nacos.api.naming.pojo.ServiceInfo;
import com.alibaba.nacos.api.remote.response.Response;
/**
* Nacos naming subscribe service response.
*
* @author xiweng.yy
*/
public class SubscribeServiceResponse extends Response {
private ServiceInfo serviceInfo;
public SubscribeServiceResponse() {
}
public SubscribeServiceResponse(int resultCode, String message, ServiceInfo serviceInfo) {
super();
setResultCode(resultCode);
setMessage(message);
this.serviceInfo = serviceInfo;
}
public ServiceInfo getServiceInfo() {
return serviceInfo;
}
public void setServiceInfo(ServiceInfo serviceInfo) {
this.serviceInfo = serviceInfo;
}
}

View File

@ -0,0 +1,37 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.remote;
/**
* abstract callback of push service.
*
* @author liuzunfei
* @version $Id: PushCallBack.java, v 0.1 2020年07月20日 1:13 PM liuzunfei Exp $
*/
public abstract class AbstractPushCallBack implements PushCallBack {
private long timeout;
public AbstractPushCallBack(long timeout) {
this.timeout = timeout;
}
@Override
public long getTimeout() {
return timeout;
}
}

View File

@ -0,0 +1,41 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.remote;
/**
* abstract request call back.
*
* @author liuzunfei
* @version $Id: AbstractRequestCallBack.java, v 0.1 2020年09月07日 3:30 PM liuzunfei Exp $
*/
public abstract class AbstractRequestCallBack implements RequestCallBack {
long timeoutMills;
public AbstractRequestCallBack(long timeoutMill) {
this.timeoutMills = timeoutMill;
}
public AbstractRequestCallBack() {
this(3000L);
}
@Override
public long getTimeout() {
return timeoutMills;
}
}

View File

@ -0,0 +1,225 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.remote;
import com.alibaba.nacos.api.remote.response.Response;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
/**
* default request future.
*
* @author liuzunfei
* @version $Id: DefaultRequestFuture.java, v 0.1 2020年09月01日 6:42 PM liuzunfei Exp $
*/
public class DefaultRequestFuture implements RequestFuture {
private long timeStamp;
private volatile boolean isDone = false;
private boolean isSuccess;
private RequestCallBack requestCallBack;
private Exception exception;
private String requestId;
private String connectionId;
private Response response;
private ScheduledFuture timeoutFuture;
TimeoutInnerTrigger timeoutInnerTrigger;
/**
* Getter method for property <tt>requestCallBack</tt>.
*
* @return property value of requestCallBack
*/
public RequestCallBack getRequestCallBack() {
return requestCallBack;
}
/**
* Getter method for property <tt>timeStamp</tt>.
*
* @return property value of timeStamp
*/
public long getTimeStamp() {
return timeStamp;
}
public DefaultRequestFuture() {
}
public DefaultRequestFuture(String connectionId, String requestId) {
this(connectionId, requestId, null, null);
}
public DefaultRequestFuture(String connectionId, String requestId, RequestCallBack requestCallBack,
TimeoutInnerTrigger timeoutInnerTrigger) {
this.timeStamp = System.currentTimeMillis();
this.requestCallBack = requestCallBack;
this.requestId = requestId;
this.connectionId = connectionId;
if (requestCallBack != null) {
this.timeoutFuture = RpcScheduledExecutor.TIMEOUT_SCHEDULER
.schedule(new TimeoutHandler(), requestCallBack.getTimeout(), TimeUnit.MILLISECONDS);
}
this.timeoutInnerTrigger = timeoutInnerTrigger;
}
public void setResponse(final Response response) {
isDone = true;
this.response = response;
this.isSuccess = response.isSuccess();
if (this.timeoutFuture != null) {
timeoutFuture.cancel(true);
}
synchronized (this) {
notifyAll();
}
callBacInvoke();
}
public void setFailResult(Exception e) {
isDone = true;
isSuccess = false;
this.exception = e;
synchronized (this) {
notifyAll();
}
callBacInvoke();
}
private void callBacInvoke() {
if (requestCallBack != null) {
if (requestCallBack.getExecutor() != null) {
requestCallBack.getExecutor().execute(new CallBackHandler());
} else {
new CallBackHandler().run();
}
}
}
public String getRequestId() {
return this.requestId;
}
@Override
public boolean isDone() {
return isDone;
}
@Override
public Response get() throws InterruptedException {
synchronized (this) {
while (!isDone) {
wait();
}
}
return response;
}
@Override
public Response get(long timeout) throws TimeoutException, InterruptedException {
if (timeout < 0) {
synchronized (this) {
while (!isDone) {
wait();
}
}
} else if (timeout > 0) {
long end = System.currentTimeMillis() + timeout;
long waitTime = timeout;
synchronized (this) {
while (!isDone && waitTime > 0) {
wait(waitTime);
waitTime = end - System.currentTimeMillis();
}
}
}
if (isDone) {
return response;
} else {
if (timeoutInnerTrigger != null) {
timeoutInnerTrigger.triggerOnTimeout();
}
throw new TimeoutException("request timeout after " + timeout + " milliseconds, requestId=" + requestId);
}
}
class CallBackHandler implements Runnable {
@Override
public void run() {
if (exception != null) {
requestCallBack.onException(exception);
} else {
requestCallBack.onResponse(response);
}
}
}
class TimeoutHandler implements Runnable {
public TimeoutHandler() {
}
@Override
public void run() {
setFailResult(new TimeoutException(
"Timeout After " + requestCallBack.getTimeout() + " milliseconds,requestId =" + requestId));
}
}
public interface TimeoutInnerTrigger {
/**
* triggered on timeout .
*/
public void triggerOnTimeout();
}
/**
* Getter method for property <tt>connectionId</tt>.
*
* @return property value of connectionId
*/
public String getConnectionId() {
return connectionId;
}
/**
* Setter method for property <tt>timeoutFuture</tt>.
*
* @param timeoutFuture value to be assigned to property timeoutFuture
*/
public void setTimeoutFuture(ScheduledFuture timeoutFuture) {
this.timeoutFuture = timeoutFuture;
}
}

View File

@ -0,0 +1,94 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.remote;
import com.alibaba.nacos.api.remote.request.Request;
import com.alibaba.nacos.api.remote.response.Response;
import org.reflections.Reflections;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* payload regitry,include all request and response.
*
* @author liuzunfei
* @version $Id: PayloadRegistry.java, v 0.1 2020年09月01日 10:56 AM liuzunfei Exp $
*/
public class PayloadRegistry {
private static final Map<String, Class> REGISTRY_REQUEST = new HashMap<String, Class>();
static boolean initialized = false;
public static void init() {
scan();
}
private static synchronized void scan() {
if (initialized) {
return;
}
List<String> requestScanPackage = Arrays
.asList("com.alibaba.nacos.api.naming.remote.request", "com.alibaba.nacos.api.config.remote.request",
"com.alibaba.nacos.api.remote.request", "com.alibaba.nacos.naming.cluster.remote.request");
for (String pkg : requestScanPackage) {
Reflections reflections = new Reflections(pkg);
Set<Class<? extends Request>> subTypesRequest = reflections.getSubTypesOf(Request.class);
for (Class clazz : subTypesRequest) {
register(clazz.getSimpleName(), clazz);
}
}
List<String> responseScanPackage = Arrays
.asList("com.alibaba.nacos.api.naming.remote.response",
"com.alibaba.nacos.api.config.remote.response", "com.alibaba.nacos.api.remote.response",
"com.alibaba.nacos.naming.cluster.remote.response");
for (String pkg : responseScanPackage) {
Reflections reflections = new Reflections(pkg);
Set<Class<? extends Response>> subTypesOfResponse = reflections.getSubTypesOf(Response.class);
for (Class clazz : subTypesOfResponse) {
register(clazz.getSimpleName(), clazz);
}
}
initialized = true;
}
static void register(String type, Class clazz) {
if (Modifier.isAbstract(clazz.getModifiers())) {
return;
}
if (Modifier.isInterface(clazz.getModifiers())) {
return;
}
if (REGISTRY_REQUEST.containsKey(type)) {
throw new RuntimeException(String.format("Fail to register, type:%s ,clazz:%s ", type, clazz.getName()));
}
REGISTRY_REQUEST.put(type, clazz);
}
public static Class getClassByType(String type) {
return REGISTRY_REQUEST.get(type);
}
}

View File

@ -0,0 +1,46 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.remote;
/**
* callback of push service.
*
* @author liuzunfei
* @version $Id: PushCallBack.java, v 0.1 2020年07月20日 1:13 PM liuzunfei Exp $
*/
public interface PushCallBack {
/**
* Push timeout mills.
*
* @return timeout milliseconds
*/
long getTimeout();
/**
* invoked on success.
*/
void onSuccess();
/**
* invoked on fail.
*
* @param e exception throwed.
*/
void onFail(Throwable e);
}

View File

@ -0,0 +1,41 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.remote;
/**
* constants define of remote.
*
* @author liuzunfei
* @version $Id: ConnectionMetaConstants.java, v 0.1 2020年08月13日 1:05 PM liuzunfei Exp $
*/
public class RemoteConstants {
/**
* label key value define.
*/
public static final String LABEL_SOURCE = "source";
public static final String LABEL_SOURCE_SDK = "sdk";
public static final String LABEL_SOURCE_CLUSTER = "cluster";
public static final String LABEL_MODULE = "module";
public static final String LABEL_MODULE_CONFIG = "config";
public static final String LABEL_MODULE_NAMING = "naming";
}

View File

@ -0,0 +1,59 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.remote;
import com.alibaba.nacos.api.remote.response.Response;
import java.util.concurrent.Executor;
/**
* call back for request.
*
* @author liuzunfei
* @version $Id: PushCallBack.java, v 0.1 2020年09月01日 6:33 PM liuzunfei Exp $
*/
public interface RequestCallBack<T extends Response> {
/**
* get executor on callback.
*
* @return executor.
*/
public Executor getExecutor();
/**
* get timeout mills.
*
* @return timeouts.
*/
public long getTimeout();
/**
* called on success.
*
* @param response response received.
*/
public void onResponse(T response);
/**
* called on failed.
*
* @param e exception throwed.
*/
public void onException(Throwable e);
}

View File

@ -0,0 +1,53 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.remote;
import com.alibaba.nacos.api.remote.response.Response;
/**
* future for request.
*
* @author liuzunfei
* @version $Id: RequestFuture.java, v 0.1 2020年09月01日 6:31 PM liuzunfei Exp $
*/
public interface RequestFuture {
/**
* check that it is done or not..
*
* @return is done .
*/
boolean isDone();
/**
* get response without timeouts.
*
* @return return response if done.
* @throws Exception exception throws .
*/
Response get() throws Exception;
/**
* get response with a given timeouts.
*
* @param timeout timeout milliseconds.
* @return return response if done.
* @throws Exception exception throws .
*/
Response get(long timeout) throws Exception;
}

View File

@ -0,0 +1,64 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.remote;
import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.api.remote.request.Request;
import com.alibaba.nacos.api.remote.response.Response;
/**
* connection interface,define basic operation.
*
* @author liuzunfei
* @version $Id: Requester.java, v 0.1 2020年09月11日 4:05 PM liuzunfei Exp $
*/
public interface Requester {
/**
* send request.
*
* @param request request.
* @param timeoutMills mills of timeouts.
* @return response response returned.
* @throws NacosException exception throw.
*/
Response request(Request request, long timeoutMills) throws NacosException;
/**
* send request.
*
* @param request request.
* @return request future.
* @throws NacosException exception throw.
*/
RequestFuture requestFuture(Request request) throws NacosException;
/**
* send async request.
*
* @param request request.
* @param requestCallBack callback of request.
* @throws NacosException exception throw.
*/
void asyncRequest(Request request, RequestCallBack requestCallBack) throws NacosException;
/**
* close connection.
*/
void close();
}

View File

@ -0,0 +1,45 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.remote;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadFactory;
/**
* rpc scheduler executor .
*
* @author liuzunfei
* @version $Id: RpcScheduledExecutor.java, v 0.1 2020年09月07日 4:12 PM liuzunfei Exp $
*/
public class RpcScheduledExecutor extends ScheduledThreadPoolExecutor {
public static final RpcScheduledExecutor TIMEOUT_SCHEDULER = new RpcScheduledExecutor(1,
"com.alibaba.nacos.remote.TimerScheduler");
public static final RpcScheduledExecutor COMMON_SERVER_EXECUTOR = new RpcScheduledExecutor(1,
"com.alibaba.nacos.remote.ServerCommonScheduler");
public RpcScheduledExecutor(int corePoolSize, final String threadName) {
super(corePoolSize, new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
return new Thread(r, threadName);
}
});
}
}

View File

@ -0,0 +1,32 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.remote.request;
/**
* client active detection request from server.
*
* @author liuzunfei
* @version $Id: ClientDetectionRequest.java, v 0.1 2021年01月20日 2:42 PM liuzunfei Exp $
*/
public class ClientDetectionRequest extends ServerRequest {
@Override
public String getModule() {
return "internal";
}
}

View File

@ -0,0 +1,71 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.remote.request;
/**
* ConnectResetRequest.
*
* @author liuzunfei
* @version $Id: ConnectResetRequest.java, v 0.1 2020年07月15日 11:11 AM liuzunfei Exp $
*/
public class ConnectResetRequest extends ServerRequest {
String serverIp;
String serverPort;
@Override
public String getModule() {
return "internal";
}
/**
* Getter method for property <tt>serverIp</tt>.
*
* @return property value of serverIp
*/
public String getServerIp() {
return serverIp;
}
/**
* Setter method for property <tt>serverIp</tt>.
*
* @param serverIp value to be assigned to property serverIp
*/
public void setServerIp(String serverIp) {
this.serverIp = serverIp;
}
/**
* Getter method for property <tt>serverPort</tt>.
*
* @return property value of serverPort
*/
public String getServerPort() {
return serverPort;
}
/**
* Setter method for property <tt>serverPort</tt>.
*
* @param serverPort value to be assigned to property serverPort
*/
public void setServerPort(String serverPort) {
this.serverPort = serverPort;
}
}

View File

@ -0,0 +1,74 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.remote.request;
import com.alibaba.nacos.api.ability.ClientAbilities;
import java.util.HashMap;
import java.util.Map;
/**
* request to setup a connection.
*
* @author liuzunfei
* @version $Id: ConnectionSetupRequest.java, v 0.1 2020年08月06日 2:42 PM liuzunfei Exp $
*/
public class ConnectionSetupRequest extends InternalRequest {
private String clientVersion;
private ClientAbilities abilities;
private String tenant;
private Map<String, String> labels = new HashMap<String, String>();
public ConnectionSetupRequest() {
}
public String getClientVersion() {
return clientVersion;
}
public void setClientVersion(String clientVersion) {
this.clientVersion = clientVersion;
}
public Map<String, String> getLabels() {
return labels;
}
public void setLabels(Map<String, String> labels) {
this.labels = labels;
}
public String getTenant() {
return tenant;
}
public void setTenant(String tenant) {
this.tenant = tenant;
}
public ClientAbilities getAbilities() {
return abilities;
}
public void setAbilities(ClientAbilities abilities) {
this.abilities = abilities;
}
}

View File

@ -0,0 +1,27 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.remote.request;
/**
* request to check server if unimpeded.
*
* @author liuzunfei
* @version $Id: ServerCheckRequest.java, v 0.1 2020年07月22日 8:32 PM liuzunfei Exp $
*/
public class HealthCheckRequest extends InternalRequest {
}

View File

@ -0,0 +1,32 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.remote.request;
/**
* internal request .
*
* @author liuzunfei
* @version $Id: InternalRequest.java, v 0.1 2020年07月22日 8:33 PM liuzunfei Exp $
*/
@SuppressWarnings("PMD.AbstractClassShouldStartWithAbstractNamingRule")
public abstract class InternalRequest extends Request {
@Override
public String getModule() {
return "internal";
}
}

View File

@ -0,0 +1,101 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.remote.request;
/**
* push ack request.
*
* @author liuzunfei
* @version $Id: PushAckRequest.java, v 0.1 2020年07月29日 8:25 PM liuzunfei Exp $
*/
public class PushAckRequest extends InternalRequest {
private String requestId;
private boolean success;
private Exception exception;
/**
* build push ack request.
*
* @param requestId requestId.
* @return request.
*/
public static PushAckRequest build(String requestId, boolean success) {
PushAckRequest request = new PushAckRequest();
request.requestId = requestId;
request.success = success;
return request;
}
/**
* Getter method for property <tt>requestId</tt>.
*
* @return property value of requestId
*/
@Override
public String getRequestId() {
return requestId;
}
/**
* Setter method for property <tt>requestId</tt>.
*
* @param requestId value to be assigned to property requestId
*/
@Override
public void setRequestId(String requestId) {
this.requestId = requestId;
}
/**
* Getter method for property <tt>success</tt>.
*
* @return property value of success
*/
public boolean isSuccess() {
return success;
}
/**
* Setter method for property <tt>success</tt>.
*
* @param success value to be assigned to property success
*/
public void setSuccess(boolean success) {
this.success = success;
}
/**
* Setter method for property <tt>exception</tt>.
*
* @param exception value to be assigned to property exception
*/
public void setException(Exception exception) {
this.exception = exception;
}
/**
* Getter method for property <tt>exception</tt>.
*
* @return property value of exception
*/
public Exception getException() {
return exception;
}
}

View File

@ -0,0 +1,120 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.remote.request;
import java.util.HashMap;
import java.util.Map;
/**
* Request.
*
* @author liuzunfei
*/
@SuppressWarnings("PMD.AbstractClassShouldStartWithAbstractNamingRule")
public abstract class Request {
private final Map<String, String> headers = new HashMap<String, String>();
private String requestId;
/**
* put header.
*
* @param key key of value.
* @param value value.
*/
public void putHeader(String key, String value) {
headers.put(key, value);
}
/**
* put headers .
*
* @param headers headers to put.
*/
public void putAllHeader(Map<String, String> headers) {
if (headers == null || headers.isEmpty()) {
return;
}
this.headers.putAll(headers);
}
/**
* get a header value .
*
* @param key key of value.
* @return return value of key. return null if not exist.
*/
public String getHeader(String key) {
return headers.get(key);
}
/**
* get a header value of defaut value.
*
* @param key key of value.
* @param defaultValue default value if key is not exist.
* @return return final value.
*/
public String getHeader(String key, String defaultValue) {
String value = headers.get(key);
return (value == null) ? defaultValue : value;
}
/**
* Getter method for property <tt>requestId</tt>.
*
* @return property value of requestId
*/
public String getRequestId() {
return requestId;
}
/**
* Setter method for property <tt>requestId</tt>.
*
* @param requestId value to be assigned to property requestId
*/
public void setRequestId(String requestId) {
this.requestId = requestId;
}
/**
* Getter method for property <tt>type</tt>.
*
* @return property value of type
*/
public abstract String getModule();
/**
* Getter method for property <tt>headers</tt>.
*
* @return property value of headers
*/
public Map<String, String> getHeaders() {
return headers;
}
public void clearHeaders() {
this.headers.clear();
}
@Override
public String toString() {
return this.getClass().getSimpleName() + "{" + "headers=" + headers + ", requestId='" + requestId + '\'' + '}';
}
}

View File

@ -0,0 +1,115 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.remote.request;
import java.util.HashMap;
import java.util.Map;
/**
* RequestMeta info.
*
* @author liuzunfei
* @version $Id: RequestMeta.java, v 0.1 2020年07月14日 10:32 AM liuzunfei Exp $
*/
public class RequestMeta {
private String connectionId = "";
private String clientIp = "";
private String clientVersion = "";
private Map<String, String> labels = new HashMap<String, String>();
/**
* Getter method for property <tt>clientVersion</tt>.
*
* @return property value of clientVersion
*/
public String getClientVersion() {
return clientVersion;
}
/**
* Setter method for property <tt>clientVersion</tt>.
*
* @param clientVersion value to be assigned to property clientVersion
*/
public void setClientVersion(String clientVersion) {
this.clientVersion = clientVersion;
}
/**
* Getter method for property <tt>labels</tt>.
*
* @return property value of labels
*/
public Map<String, String> getLabels() {
return labels;
}
/**
* Setter method for property <tt>labels</tt>.
*
* @param labels value to be assigned to property labels
*/
public void setLabels(Map<String, String> labels) {
this.labels = labels;
}
/**
* Getter method for property <tt>connectionId</tt>.
*
* @return property value of connectionId
*/
public String getConnectionId() {
return connectionId;
}
/**
* Setter method for property <tt>connectionId</tt>.
*
* @param connectionId value to be assigned to property connectionId
*/
public void setConnectionId(String connectionId) {
this.connectionId = connectionId;
}
/**
* Getter method for property <tt>clientIp</tt>.
*
* @return property value of clientIp
*/
public String getClientIp() {
return clientIp;
}
/**
* Setter method for property <tt>clientIp</tt>.
*
* @param clientIp value to be assigned to property clientIp
*/
public void setClientIp(String clientIp) {
this.clientIp = clientIp;
}
@Override
public String toString() {
return "RequestMeta{" + "connectionId='" + connectionId + '\'' + ", clientIp='" + clientIp + '\''
+ ", clientVersion='" + clientVersion + '\'' + ", labels=" + labels + '}';
}
}

View File

@ -0,0 +1,27 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.remote.request;
/**
* request to check server if unimpeded.
*
* @author liuzunfei
* @version $Id: ServerCheckRequest.java, v 0.1 2020年07月22日 8:32 PM liuzunfei Exp $
*/
public class ServerCheckRequest extends InternalRequest {
}

View File

@ -0,0 +1,28 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.remote.request;
/**
* get server node loader info.
* @author liuzunfei
* @version $Id: ServerLoaderInfoRequest.java, v 0.1 2020年09月03日 2:45 PM liuzunfei Exp $
*/
public class ServerLoaderInfoRequest extends InternalRequest {
public ServerLoaderInfoRequest() {
}
}

View File

@ -0,0 +1,56 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.remote.request;
/**
* reload long connection request.
*
* @author liuzunfei
* @version $Id: ServerReloadRequest.java, v 0.1 2020年11月09日 4:35 PM liuzunfei Exp $
*/
public class ServerReloadRequest extends InternalRequest {
int reloadCount = 0;
String reloadServer;
/**
* Getter method for property <tt>reloadCount</tt>.
*
* @return property value of reloadCount
*/
public int getReloadCount() {
return reloadCount;
}
/**
* Setter method for property <tt>reloadCount</tt>.
*
* @param reloadCount value to be assigned to property reloadCount
*/
public void setReloadCount(int reloadCount) {
this.reloadCount = reloadCount;
}
public String getReloadServer() {
return reloadServer;
}
public void setReloadServer(String reloadServer) {
this.reloadServer = reloadServer;
}
}

View File

@ -0,0 +1,28 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.remote.request;
/**
* ServerPushResponse.
*
* @author liuzunfei
* @version $Id: ServerPushResponse.java, v 0.1 2020年07月20日 1:21 PM liuzunfei Exp $
*/
@SuppressWarnings("PMD.AbstractClassShouldStartWithAbstractNamingRule")
public abstract class ServerRequest extends Request {
}

View File

@ -0,0 +1,27 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.remote.response;
/**
* response of client active detection check.
*
* @author liuzunfei
* @version $Id: ServerCheckResponse.java, v 0.1 2021年01月20日 10:37 PM liuzunfei Exp $
*/
public class ClientDetectionResponse extends Response {
}

View File

@ -0,0 +1,27 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.remote.response;
/**
* connection reset response.
*
* @author liuzunfei
* @version $Id: ConnectResetResponse.java, v 0.1 2020年09月01日 2:43 PM liuzunfei Exp $
*/
public class ConnectResetResponse extends Response {
}

View File

@ -0,0 +1,27 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.remote.response;
/**
* UnKnowResponse.
*
* @author liuzunfei
* @version $Id: UnKnowResponse.java, v 0.1 2020年07月16日 9:47 PM liuzunfei Exp $
*/
public class ErrorResponse extends Response {
}

View File

@ -0,0 +1,27 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.remote.response;
/**
* response of server check.
*
* @author liuzunfei
* @version $Id: ServerCheckResponse.java, v 0.1 2020年07月22日 8:37 PM liuzunfei Exp $
*/
public class HealthCheckResponse extends Response {
}

View File

@ -0,0 +1,128 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.remote.response;
/**
* abstract response model via rpc channel.
*
* @author liuzunfei
* @version $Id: Response.java, v 0.1 2020年07月13日 6:03 PM liuzunfei Exp $
*/
@SuppressWarnings("PMD.AbstractClassShouldStartWithAbstractNamingRule")
public abstract class Response {
int resultCode = ResponseCode.SUCCESS.getCode();
int errorCode;
String message;
String requestId;
/**
* Getter method for property <tt>requestId</tt>.
*
* @return property value of requestId
*/
public String getRequestId() {
return requestId;
}
/**
* Setter method for property <tt>requestId</tt>.
*
* @param requestId value to be assigned to property requestId
*/
public void setRequestId(String requestId) {
this.requestId = requestId;
}
/**
* Check Response is Successed.
*
* @return success or not.
*/
public boolean isSuccess() {
return this.resultCode == ResponseCode.SUCCESS.getCode();
}
/**
* Getter method for property <tt>resultCode</tt>.
*
* @return property value of resultCode
*/
public int getResultCode() {
return resultCode;
}
/**
* Setter method for property <tt>resultCode</tt>.
*
* @param resultCode value to be assigned to property resultCode
*/
public void setResultCode(int resultCode) {
this.resultCode = resultCode;
}
/**
* Getter method for property <tt>message</tt>.
*
* @return property value of message
*/
public String getMessage() {
return message;
}
/**
* Setter method for property <tt>message</tt>.
*
* @param message value to be assigned to property message
*/
public void setMessage(String message) {
this.message = message;
}
/**
* Getter method for property <tt>errorCode</tt>.
*
* @return property value of errorCode
*/
public int getErrorCode() {
return errorCode;
}
/**
* Setter method for property <tt>errorCode</tt>.
*
* @param errorCode value to be assigned to property errorCode
*/
public void setErrorCode(int errorCode) {
this.errorCode = errorCode;
}
public void setErrorInfo(int errorCode, String errorMsg) {
this.resultCode = ResponseCode.FAIL.getCode();
this.errorCode = errorCode;
this.message = errorMsg;
}
@Override
public String toString() {
return "Response{" + "resultCode=" + resultCode + ", errorCode=" + errorCode + ", message='" + message + '\''
+ ", requestId='" + requestId + '\'' + '}';
}
}

View File

@ -0,0 +1,81 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.remote.response;
/**
* ResponseCode.
*
* @author liuzunfei
* @version $Id: ResponseCode.java, v 0.1 2020年07月14日 2:04 PM liuzunfei Exp $
*/
public enum ResponseCode {
/**
* Request success.
*/
SUCCESS(200, "Response ok"),
/**
* Request failed.
*/
FAIL(500, "Response fail");
int code;
String desc;
ResponseCode(int code, String desc) {
this.code = code;
this.desc = desc;
}
/**
* Getter method for property <tt>code</tt>.
*
* @return property value of code
*/
public int getCode() {
return code;
}
/**
* Setter method for property <tt>code</tt>.
*
* @param code value to be assigned to property code
*/
public void setCode(int code) {
this.code = code;
}
/**
* Getter method for property <tt>desc</tt>.
*
* @return property value of desc
*/
public String getDesc() {
return desc;
}
/**
* Setter method for property <tt>desc</tt>.
*
* @param desc value to be assigned to property desc
*/
public void setDesc(String desc) {
this.desc = desc;
}
}

View File

@ -0,0 +1,44 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.remote.response;
/**
* response of server check.
*
* @author liuzunfei
* @version $Id: ServerCheckResponse.java, v 0.1 2020年07月22日 8:37 PM liuzunfei Exp $
*/
public class ServerCheckResponse extends Response {
private String connectionId;
public ServerCheckResponse() {
}
public ServerCheckResponse(String connectionId) {
this.connectionId = connectionId;
}
public String getConnectionId() {
return connectionId;
}
public void setConnectionId(String connectionId) {
this.connectionId = connectionId;
}
}

View File

@ -0,0 +1,59 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.remote.response;
import java.util.HashMap;
import java.util.Map;
/**
* server loader info response.
*
* @author liuzunfei
* @version $Id: ServerLoaderInfoResponse.java, v 0.1 2020年09月03日 2:46 PM liuzunfei Exp $
*/
public class ServerLoaderInfoResponse extends Response {
String address;
Map<String, String> loaderMetrics = new HashMap<String, String>();
public String getMetricsValue(String key) {
return loaderMetrics.get(key);
}
public void putMetricsValue(String key, String value) {
this.loaderMetrics.put(key, value);
}
/**
* Getter method for property <tt>loaderMetrics</tt>.
*
* @return property value of loaderMetrics
*/
public Map<String, String> getLoaderMetrics() {
return loaderMetrics;
}
/**
* Setter method for property <tt>loaderMetrics</tt>.
*
* @param loaderMetrics value to be assigned to property loaderMetrics
*/
public void setLoaderMetrics(Map<String, String> loaderMetrics) {
this.loaderMetrics = loaderMetrics;
}
}

View File

@ -0,0 +1,27 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.remote.response;
/**
* server reload response.
*
* @author liuzunfei
* @version $Id: ServerReloadResponse.java, v 0.1 2020年11月09日 4:37 PM liuzunfei Exp $
*/
public class ServerReloadResponse extends Response {
}

View File

@ -34,5 +34,17 @@ public enum SelectorType {
/**
* select by label.
*/
label
label,
/**
* select by cluster.
*/
cluster,
/**
* select by health state.
*/
health,
/**
* select by enable state.
*/
enable
}

View File

@ -0,0 +1,96 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.utils;
import java.io.IOException;
import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.UnknownHostException;
import java.util.Enumeration;
/**
* Net utils.
*
* @author xuanyin.zy
*/
public class NetUtils {
private static String localIp;
/**
* Get local ip.
*
* @return local ip
*/
public static String localIP() {
if (!StringUtils.isEmpty(localIp)) {
return localIp;
}
String ip = System.getProperty("com.alibaba.nacos.client.naming.local.ip", findFirstNonLoopbackAddress());
return localIp = ip;
}
private static String findFirstNonLoopbackAddress() {
InetAddress result = null;
try {
int lowest = Integer.MAX_VALUE;
for (Enumeration<NetworkInterface> nics = NetworkInterface.getNetworkInterfaces();
nics.hasMoreElements(); ) {
NetworkInterface ifc = nics.nextElement();
if (ifc.isUp()) {
if (ifc.getIndex() < lowest || result == null) {
lowest = ifc.getIndex();
} else {
continue;
}
for (Enumeration<InetAddress> addrs = ifc.getInetAddresses(); addrs.hasMoreElements(); ) {
InetAddress address = addrs.nextElement();
boolean isLegalIpVersion =
Boolean.parseBoolean(System.getProperty("java.net.preferIPv6Addresses"))
? address instanceof Inet6Address : address instanceof Inet4Address;
if (isLegalIpVersion && !address.isLoopbackAddress()) {
result = address;
}
}
}
}
} catch (IOException ex) {
//ignore
}
if (result != null) {
return result.getHostAddress();
}
try {
return InetAddress.getLocalHost().getHostAddress();
} catch (UnknownHostException e) {
//ignore
}
return "resolve_failed";
}
}

View File

@ -0,0 +1,54 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.
*/
syntax = "proto3";
import "google/protobuf/any.proto";
import "google/protobuf/timestamp.proto";
option java_multiple_files = true;
option java_package = "com.alibaba.nacos.api.grpc.auto";
message Metadata {
string type = 3;
string clientIp = 8;
map<string, string> headers = 7;
}
message Payload {
Metadata metadata = 2;
google.protobuf.Any body = 3;
}
service RequestStream {
// build a streamRequest
rpc requestStream (Payload) returns (stream Payload) {
}
}
service Request {
// Sends a commonRequest
rpc request (Payload) returns (Payload) {
}
}
service BiRequestStream {
// Sends a commonRequest
rpc requestBiStream (stream Payload) returns (stream Payload) {
}
}

View File

@ -0,0 +1,60 @@
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.alibaba.nacos.api.naming;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
public class ServerNamingAbilityTest {
private static ObjectMapper jacksonMapper;
@BeforeClass
public static void setUpClass() throws Exception {
jacksonMapper = new ObjectMapper();
jacksonMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
jacksonMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
}
@Test
public void testDeserializeServerNamingAbilityForNonExistItem() throws JsonProcessingException {
String nonExistItemJson = "{\"exampleAbility\":false}";
ServerNamingAbility actual = jacksonMapper.readValue(nonExistItemJson, ServerNamingAbility.class);
assertFalse(actual.isSupportJraft());
}
@Test
public void testEquals() throws JsonProcessingException {
ServerNamingAbility expected = new ServerNamingAbility();
expected.setSupportJraft(true);
String serializeJson = jacksonMapper.writeValueAsString(expected);
ServerNamingAbility actual = jacksonMapper.readValue(serializeJson, ServerNamingAbility.class);
assertEquals(expected, actual);
actual = new ServerNamingAbility();
assertNotEquals(expected, actual);
actual.setSupportJraft(true);
assertEquals(expected, actual);
}
}

View File

@ -24,6 +24,8 @@ public class TestChecker extends AbstractHealthChecker {
@JsonTypeInfo(use = Id.NAME, property = "type")
public static final String TYPE = "TEST";
private static final long serialVersionUID = 2472091207760970225L;
private String testValue;
public String getTestValue() {

View File

@ -38,6 +38,15 @@ public interface AuthManager {
*/
User login(Object request) throws AccessException;
/**
* Authentication of request, identify the user who request the resource.
*
* @param request where we can find the user information
* @return user related to this request, null if no user info is found.
* @throws AccessException if authentication is failed
*/
User loginRemote(Object request) throws AccessException;
/**
* Authorization of request, constituted with resource and user.
*

View File

@ -28,5 +28,9 @@ public enum AuthSystemTypes {
/**
* Nacos builtin auth system.
*/
NACOS
NACOS,
/**
* LDAP.
*/
LDAP
}

View File

@ -54,7 +54,7 @@
<artifactId>log4j-api</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
@ -64,13 +64,14 @@
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>nacos-common</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>nacos-api</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
@ -83,11 +84,6 @@
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<artifactId>commons-codec</artifactId>
<groupId>commons-codec</groupId>
@ -103,6 +99,14 @@
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpasyncclient</artifactId>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
</dependency>
<dependency>
<groupId>net.jcip</groupId>
<artifactId>jcip-annotations</artifactId>
@ -117,7 +121,6 @@
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
</dependency>
</dependencies>
<build>
@ -126,10 +129,223 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>6</source>
<target>6</target>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>release-sign-artifacts</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<keepDependenciesWithProvidedScope>false</keepDependenciesWithProvidedScope>
<promoteTransitiveDependencies>true</promoteTransitiveDependencies>
<createDependencyReducedPom>false</createDependencyReducedPom>
<minimizeJar>false</minimizeJar>
<createSourcesJar>true</createSourcesJar>
<shadeSourcesContent>true</shadeSourcesContent>
<artifactSet>
<includes>
<include>io.grpc:*</include>
<include>io.opencensus:*</include>
<include>io.perfmark:*</include>
<include>com.google.guava:guava</include>
<include>com.google.guava:failureaccess</include>
<include>com.google.errorprone:error_prone_annotations</include>
<include>com.google.j2objc:j2objc-annotations</include>
<include>com.google.code.gson:gson</include>
<include>com.google.protobuf:protobuf-java</include>
<include>com.alibaba.nacos:nacos-api</include>
<include>com.alibaba.nacos:nacos-common</include>
<include>org.checkerframework:checker-qual</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>io.grpc</pattern>
<shadedPattern>com.alibaba.nacos.shaded.io.grpc</shadedPattern>
<excludes>
<exclude>io.grpc.netty.shaded.io.grpc.netty.*</exclude>
</excludes>
</relocation>
<relocation>
<pattern>io.grpc.netty.shaded.io.grpc.netty</pattern>
<shadedPattern>com.alibaba.nacos.shaded.io.grpc.netty.shaded.io.grpc.netty
</shadedPattern>
<includes>
<include>io.grpc.netty.shaded.io.grpc.netty.*</include>
</includes>
</relocation>
<relocation>
<pattern>com.google</pattern>
<shadedPattern>com.alibaba.nacos.shaded.com.google</shadedPattern>
</relocation>
<relocation>
<pattern>io.perfmark</pattern>
<shadedPattern>com.alibaba.nacos.shaded.io.perfmark</shadedPattern>
</relocation>
<relocation>
<pattern>io.opencensus</pattern>
<shadedPattern>com.alibaba.nacos.shaded.io.opencensus</shadedPattern>
</relocation>
<relocation>
<pattern>org.codehaus</pattern>
<shadedPattern>com.alibaba.nacos.shaded.org.codehaus</shadedPattern>
</relocation>
<relocation>
<pattern>org.checkerframework</pattern>
<shadedPattern>com.alibaba.nacos.shaded.org.checkerframework</shadedPattern>
</relocation>
<relocation>
<pattern>android.annotation</pattern>
<shadedPattern>com.alibaba.nacos.shaded.android.annotation</shadedPattern>
</relocation>
<relocation>
<pattern>org.example</pattern>
<shadedPattern>com.alibaba.nacos.shaded.org.example</shadedPattern>
</relocation>
</relocations>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"/>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>release-nacos</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<keepDependenciesWithProvidedScope>false</keepDependenciesWithProvidedScope>
<promoteTransitiveDependencies>true</promoteTransitiveDependencies>
<createDependencyReducedPom>false</createDependencyReducedPom>
<minimizeJar>false</minimizeJar>
<createSourcesJar>true</createSourcesJar>
<shadeSourcesContent>true</shadeSourcesContent>
<artifactSet>
<includes>
<include>io.grpc:*</include>
<include>io.opencensus:*</include>
<include>io.perfmark:*</include>
<include>com.google.guava:guava</include>
<include>com.google.guava:failureaccess</include>
<include>com.google.errorprone:error_prone_annotations</include>
<include>com.google.j2objc:j2objc-annotations</include>
<include>com.google.code.gson:gson</include>
<include>com.google.protobuf:protobuf-java</include>
<include>com.alibaba.nacos:nacos-api</include>
<include>com.alibaba.nacos:nacos-common</include>
<include>org.checkerframework:checker-qual</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>io.grpc</pattern>
<shadedPattern>com.alibaba.nacos.shaded.io.grpc</shadedPattern>
<excludes>
<exclude>io.grpc.netty.shaded.io.grpc.netty.*</exclude>
</excludes>
</relocation>
<relocation>
<pattern>io.grpc.netty.shaded.io.grpc.netty</pattern>
<shadedPattern>com.alibaba.nacos.shaded.io.grpc.netty.shaded.io.grpc.netty
</shadedPattern>
<includes>
<include>io.grpc.netty.shaded.io.grpc.netty.*</include>
</includes>
</relocation>
<relocation>
<pattern>com.google</pattern>
<shadedPattern>com.alibaba.nacos.shaded.com.google</shadedPattern>
</relocation>
<relocation>
<pattern>io.perfmark</pattern>
<shadedPattern>com.alibaba.nacos.shaded.io.perfmark</shadedPattern>
</relocation>
<relocation>
<pattern>io.opencensus</pattern>
<shadedPattern>com.alibaba.nacos.shaded.io.opencensus</shadedPattern>
</relocation>
<relocation>
<pattern>org.codehaus</pattern>
<shadedPattern>com.alibaba.nacos.shaded.org.codehaus</shadedPattern>
</relocation>
<relocation>
<pattern>org.checkerframework</pattern>
<shadedPattern>com.alibaba.nacos.shaded.org.checkerframework</shadedPattern>
</relocation>
<relocation>
<pattern>android.annotation</pattern>
<shadedPattern>com.alibaba.nacos.shaded.android.annotation</shadedPattern>
</relocation>
<relocation>
<pattern>org.example</pattern>
<shadedPattern>com.alibaba.nacos.shaded.org.example</shadedPattern>
</relocation>
</relocations>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"/>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -25,25 +25,20 @@ import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.client.config.filter.impl.ConfigFilterChainManager;
import com.alibaba.nacos.client.config.filter.impl.ConfigRequest;
import com.alibaba.nacos.client.config.filter.impl.ConfigResponse;
import com.alibaba.nacos.client.config.http.HttpAgent;
import com.alibaba.nacos.client.config.http.MetricsHttpAgent;
import com.alibaba.nacos.client.config.http.ServerHttpAgent;
import com.alibaba.nacos.client.config.impl.ClientWorker;
import com.alibaba.nacos.client.config.impl.LocalConfigInfoProcessor;
import com.alibaba.nacos.client.config.impl.LocalEncryptedDataKeyProcessor;
import com.alibaba.nacos.client.config.impl.ServerListManager;
import com.alibaba.nacos.client.config.utils.ContentUtils;
import com.alibaba.nacos.client.config.utils.ParamUtils;
import com.alibaba.nacos.client.utils.LogUtils;
import com.alibaba.nacos.client.utils.ParamUtil;
import com.alibaba.nacos.client.utils.ValidatorUtils;
import com.alibaba.nacos.common.http.HttpRestResult;
import com.alibaba.nacos.common.utils.StringUtils;
import org.slf4j.Logger;
import java.net.HttpURLConnection;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
/**
@ -56,12 +51,11 @@ public class NacosConfigService implements ConfigService {
private static final Logger LOGGER = LogUtils.logger(NacosConfigService.class);
private static final long POST_TIMEOUT = 3000L;
/**
* http agent.
* will be deleted in 2.0 later versions
*/
private final HttpAgent agent;
@Deprecated
ServerHttpAgent agent = null;
/**
* long polling.
@ -70,24 +64,20 @@ public class NacosConfigService implements ConfigService {
private String namespace;
private final String encode;
private final ConfigFilterChainManager configFilterChainManager;
public NacosConfigService(Properties properties) throws NacosException {
ValidatorUtils.checkInitParam(properties);
String encodeTmp = properties.getProperty(PropertyKeyConst.ENCODE);
if (StringUtils.isBlank(encodeTmp)) {
this.encode = Constants.ENCODE;
} else {
this.encode = encodeTmp.trim();
}
initNamespace(properties);
this.configFilterChainManager = new ConfigFilterChainManager(properties);
ServerListManager serverListManager = new ServerListManager(properties);
serverListManager.start();
this.worker = new ClientWorker(this.configFilterChainManager, serverListManager, properties);
// will be deleted in 2.0 later versions
agent = new ServerHttpAgent(serverListManager);
this.agent = new MetricsHttpAgent(new ServerHttpAgent(properties));
this.agent.start();
this.worker = new ClientWorker(this.agent, this.configFilterChainManager, properties);
}
private void initNamespace(Properties properties) {
@ -120,7 +110,19 @@ public class NacosConfigService implements ConfigService {
@Override
public boolean publishConfig(String dataId, String group, String content, String type) throws NacosException {
return publishConfigInner(namespace, dataId, group, null, null, null, content, type);
return publishConfigInner(namespace, dataId, group, null, null, null, content, type, null);
}
@Override
public boolean publishConfigCas(String dataId, String group, String content, String casMd5) throws NacosException {
return publishConfigInner(namespace, dataId, group, null, null, null, content,
ConfigType.getDefaultType().getType(), casMd5);
}
@Override
public boolean publishConfigCas(String dataId, String group, String content, String casMd5, String type)
throws NacosException {
return publishConfigInner(namespace, dataId, group, null, null, null, content, type, casMd5);
}
@Override
@ -143,10 +145,10 @@ public class NacosConfigService implements ConfigService {
cr.setGroup(group);
// 优先使用本地配置
String content = LocalConfigInfoProcessor.getFailover(agent.getName(), dataId, group, tenant);
String content = LocalConfigInfoProcessor.getFailover(worker.getAgentName(), dataId, group, tenant);
if (content != null) {
LOGGER.warn("[{}] [get-config] get failover ok, dataId={}, group={}, tenant={}, config={}", agent.getName(),
dataId, group, tenant, ContentUtils.truncateContent(content));
LOGGER.warn("[{}] [get-config] get failover ok, dataId={}, group={}, tenant={}, config={}",
worker.getAgentName(), dataId, group, tenant, ContentUtils.truncateContent(content));
cr.setContent(content);
String encryptedDataKey = LocalEncryptedDataKeyProcessor
.getEncryptDataKeyFailover(agent.getName(), dataId, group, tenant);
@ -157,10 +159,9 @@ public class NacosConfigService implements ConfigService {
}
try {
ConfigResponse response = worker.getServerConfig(dataId, group, tenant, timeoutMs);
ConfigResponse response = worker.getServerConfig(dataId, group, tenant, timeoutMs, false);
cr.setContent(response.getContent());
cr.setEncryptedDataKey(response.getEncryptedDataKey());
configFilterChainManager.doFilter(null, cr);
content = cr.getContent();
@ -170,12 +171,12 @@ public class NacosConfigService implements ConfigService {
throw ioe;
}
LOGGER.warn("[{}] [get-config] get from server error, dataId={}, group={}, tenant={}, msg={}",
agent.getName(), dataId, group, tenant, ioe.toString());
worker.getAgentName(), dataId, group, tenant, ioe.toString());
}
LOGGER.warn("[{}] [get-config] get snapshot ok, dataId={}, group={}, tenant={}, config={}", agent.getName(),
dataId, group, tenant, ContentUtils.truncateContent(content));
content = LocalConfigInfoProcessor.getSnapshot(agent.getName(), dataId, group, tenant);
LOGGER.warn("[{}] [get-config] get snapshot ok, dataId={}, group={}, tenant={}, config={}",
worker.getAgentName(), dataId, group, tenant, ContentUtils.truncateContent(content));
content = LocalConfigInfoProcessor.getSnapshot(worker.getAgentName(), dataId, group, tenant);
cr.setContent(content);
String encryptedDataKey = LocalEncryptedDataKeyProcessor
.getEncryptDataKeyFailover(agent.getName(), dataId, group, tenant);
@ -192,41 +193,11 @@ public class NacosConfigService implements ConfigService {
private boolean removeConfigInner(String tenant, String dataId, String group, String tag) throws NacosException {
group = blank2defaultGroup(group);
ParamUtils.checkKeyParam(dataId, group);
String url = Constants.CONFIG_CONTROLLER_PATH;
Map<String, String> params = new HashMap<String, String>(4);
params.put("dataId", dataId);
params.put("group", group);
if (StringUtils.isNotEmpty(tenant)) {
params.put("tenant", tenant);
}
if (StringUtils.isNotEmpty(tag)) {
params.put("tag", tag);
}
HttpRestResult<String> result = null;
try {
result = agent.httpDelete(url, null, params, encode, POST_TIMEOUT);
} catch (Exception ex) {
LOGGER.warn("[remove] error, " + dataId + ", " + group + ", " + tenant + ", msg: " + ex.toString());
return false;
}
if (result.ok()) {
LOGGER.info("[{}] [remove] ok, dataId={}, group={}, tenant={}", agent.getName(), dataId, group, tenant);
return true;
} else if (HttpURLConnection.HTTP_FORBIDDEN == result.getCode()) {
LOGGER.warn("[{}] [remove] error, dataId={}, group={}, tenant={}, code={}, msg={}", agent.getName(), dataId,
group, tenant, result.getCode(), result.getMessage());
throw new NacosException(result.getCode(), result.getMessage());
} else {
LOGGER.warn("[{}] [remove] error, dataId={}, group={}, tenant={}, code={}, msg={}", agent.getName(), dataId,
group, tenant, result.getCode(), result.getMessage());
return false;
}
return worker.removeConfig(dataId, group, tenant, tag);
}
private boolean publishConfigInner(String tenant, String dataId, String group, String tag, String appName,
String betaIps, String content, String type) throws NacosException {
String betaIps, String content, String type, String casMd5) throws NacosException {
group = blank2defaultGroup(group);
ParamUtils.checkParam(dataId, group, content);
@ -235,56 +206,13 @@ public class NacosConfigService implements ConfigService {
cr.setTenant(tenant);
cr.setGroup(group);
cr.setContent(content);
cr.setType(type);
configFilterChainManager.doFilter(cr, null);
content = cr.getContent();
String encryptedDataKey = (String) cr.getParameter("encryptedDataKey");
String url = Constants.CONFIG_CONTROLLER_PATH;
Map<String, String> params = new HashMap<String, String>(6);
params.put("dataId", dataId);
params.put("group", group);
params.put("content", content);
params.put("type", type);
if (StringUtils.isNotEmpty(tenant)) {
params.put("tenant", tenant);
}
if (StringUtils.isNotEmpty(appName)) {
params.put("appName", appName);
}
if (StringUtils.isNotEmpty(tag)) {
params.put("tag", tag);
}
String dataKey = (String) cr.getParameter("encryptedDataKey");
if (StringUtils.isNotEmpty(dataKey)) {
params.put("encryptedDataKey", dataKey);
}
Map<String, String> headers = new HashMap<String, String>(1);
if (StringUtils.isNotEmpty(betaIps)) {
headers.put("betaIps", betaIps);
}
HttpRestResult<String> result = null;
try {
result = agent.httpPost(url, headers, params, encode, POST_TIMEOUT);
} catch (Exception ex) {
LOGGER.warn("[{}] [publish-single] exception, dataId={}, group={}, msg={}", agent.getName(), dataId, group,
ex.toString());
return false;
}
if (result.ok()) {
LOGGER.info("[{}] [publish-single] ok, dataId={}, group={}, tenant={}, config={}", agent.getName(), dataId,
group, tenant, ContentUtils.truncateContent(content));
return true;
} else if (HttpURLConnection.HTTP_FORBIDDEN == result.getCode()) {
LOGGER.warn("[{}] [publish-single] error, dataId={}, group={}, tenant={}, code={}, msg={}", agent.getName(),
dataId, group, tenant, result.getCode(), result.getMessage());
throw new NacosException(result.getCode(), result.getMessage());
} else {
LOGGER.warn("[{}] [publish-single] error, dataId={}, group={}, tenant={}, code={}, msg={}", agent.getName(),
dataId, group, tenant, result.getCode(), result.getMessage());
return false;
}
return worker
.publishConfig(dataId, group, tenant, appName, tag, betaIps, content, encryptedDataKey, casMd5, type);
}
@Override
@ -298,7 +226,6 @@ public class NacosConfigService implements ConfigService {
@Override
public void shutDown() throws NacosException {
agent.shutdown();
worker.shutdown();
}
}

View File

@ -21,8 +21,8 @@ import com.alibaba.nacos.api.config.filter.IConfigFilterChain;
import com.alibaba.nacos.api.config.filter.IConfigRequest;
import com.alibaba.nacos.api.config.filter.IConfigResponse;
import com.alibaba.nacos.api.exception.NacosException;
import com.google.common.collect.Lists;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.ServiceLoader;
@ -34,7 +34,7 @@ import java.util.ServiceLoader;
*/
public class ConfigFilterChainManager implements IConfigFilterChain {
private final List<IConfigFilter> filters = Lists.newArrayList();
private final List<IConfigFilter> filters = new ArrayList<IConfigFilter>();
public ConfigFilterChainManager(Properties properties) {
ServiceLoader<IConfigFilter> configFilters = ServiceLoader.load(IConfigFilter.class);

Some files were not shown because too many files have changed in this diff Show More