1.server side client connection listener optimize 2. listen context and notifier updated . (#3385)

* Add gprc support-> client reconnection optimize

* Add gprc support-> 1.client connection listener optimize  2.listen context an notifier updated .

* Add gprc support->merge problem fix

* Add gprc support->check style fixed.

* Add gprc support->check style fixed and remove  gRpc classes in source package.
This commit is contained in:
nov.lzf 2020-07-20 16:27:58 +08:00 committed by GitHub
parent bd0f1a31f8
commit 85a0398978
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
46 changed files with 638 additions and 4315 deletions

View File

@ -41,24 +41,24 @@
</plugin> </plugin>
<!-- reuse when you need to update grpc model --> <!-- reuse when you need to update grpc model -->
<!--<plugin>--> <plugin>
<!--<groupId>org.xolstice.maven.plugins</groupId>--> <groupId>org.xolstice.maven.plugins</groupId>
<!--<artifactId>protobuf-maven-plugin</artifactId>--> <artifactId>protobuf-maven-plugin</artifactId>
<!--<version>0.5.0</version>--> <version>0.5.0</version>
<!--<configuration>--> <configuration>
<!--<protocArtifact>com.google.protobuf:protoc:3.3.0:exe:osx-x86_64</protocArtifact>--> <protocArtifact>com.google.protobuf:protoc:3.3.0:exe:osx-x86_64</protocArtifact>
<!--<pluginId>grpc-java</pluginId>--> <pluginId>grpc-java</pluginId>
<!--<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.20.0:exe:osx-x86_64</pluginArtifact>--> <pluginArtifact>io.grpc:protoc-gen-grpc-java:1.20.0:exe:osx-x86_64</pluginArtifact>
<!--</configuration>--> </configuration>
<!--<executions>--> <executions>
<!--<execution>--> <execution>
<!--<goals>--> <goals>
<!--<goal>compile</goal>--> <goal>compile</goal>
<!--<goal>compile-custom</goal>--> <goal>compile-custom</goal>
<!--</goals>--> </goals>
<!--</execution>--> </execution>
<!--</executions>--> </executions>
<!--</plugin>--> </plugin>
</plugins> </plugins>
</build> </build>

View File

@ -16,7 +16,6 @@
package com.alibaba.nacos.api.config.remote.request; package com.alibaba.nacos.api.config.remote.request;
/** /**
* ConfigChangeListenRequest. * ConfigChangeListenRequest.
* @author liuzunfei * @author liuzunfei
@ -24,7 +23,6 @@ package com.alibaba.nacos.api.config.remote.request;
*/ */
public class ConfigChangeListenRequest extends ConfigCommonRequest { public class ConfigChangeListenRequest extends ConfigCommonRequest {
private static final String LISTEN = "listen"; private static final String LISTEN = "listen";
private static final String UNLISTEN = "unlisten"; private static final String UNLISTEN = "unlisten";
@ -37,7 +35,6 @@ public class ConfigChangeListenRequest extends ConfigCommonRequest {
private String operation = LISTEN; private String operation = LISTEN;
public boolean isCancelListen() { public boolean isCancelListen() {
return UNLISTEN.equals(this.operation); return UNLISTEN.equals(this.operation);
} }

View File

@ -16,14 +16,14 @@
package com.alibaba.nacos.api.config.remote.response; package com.alibaba.nacos.api.config.remote.response;
import com.alibaba.nacos.api.remote.response.Response; import com.alibaba.nacos.api.remote.response.ServerPushResponse;
import com.alibaba.nacos.api.remote.response.ResponseCode;
/** /**
* ConfigChangeNotifyResponse.
* @author liuzunfei * @author liuzunfei
* @version $Id: ConfigChangeNotifyResponse.java, v 0.1 2020年07月14日 3:20 PM liuzunfei Exp $ * @version $Id: ConfigChangeNotifyResponse.java, v 0.1 2020年07月14日 3:20 PM liuzunfei Exp $
*/ */
public class ConfigChangeNotifyResponse extends Response { public class ConfigChangeNotifyResponse extends ServerPushResponse {
private String dataId; private String dataId;
@ -31,10 +31,6 @@ public class ConfigChangeNotifyResponse extends Response {
private String tenant; private String tenant;
public ConfigChangeNotifyResponse() {
}
@Override @Override
public String getType() { public String getType() {
return ConfigResponseTypeConstants.CONFIG_CHANGE_NOTIFY; return ConfigResponseTypeConstants.CONFIG_CHANGE_NOTIFY;

View File

@ -61,8 +61,8 @@ public class ConfigQueryResponse extends Response {
/** /**
* Buid fail response. * Buid fail response.
* *
* @param errorCode * @param errorCode errorCode.
* @param message * @param message message.
* @return * @return
*/ */
public static ConfigQueryResponse buildFailResponse(int errorCode, String message) { public static ConfigQueryResponse buildFailResponse(int errorCode, String message) {

File diff suppressed because it is too large Load Diff

View File

@ -1,113 +0,0 @@
/*
* 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.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: nacos_grpc_service.proto
package com.alibaba.nacos.api.grpc;
public interface GrpcMetadataOrBuilder extends
// @@protoc_insertion_point(interface_extends:GrpcMetadata)
com.google.protobuf.MessageOrBuilder {
/**
* <code>string name = 1;.</code>
*/
String getName();
/**
* <code>string name = 1;.</code>
*/
com.google.protobuf.ByteString getNameBytes();
/**
* <code>string client_ip = 2;.</code>
*/
String getClientIp();
/**
* <code>string client_ip = 2;.</code>
*/
com.google.protobuf.ByteString getClientIpBytes();
/**
* <code>string connection_id = 3;.</code>
*/
String getConnectionId();
/**
* <code>string connection_id = 3;.</code>
*/
com.google.protobuf.ByteString getConnectionIdBytes();
/**
* <code>.google.protobuf.Timestamp create_time = 4;.</code>
*/
boolean hasCreateTime();
/**
* <code>.google.protobuf.Timestamp create_time = 4;.</code>
*/
com.google.protobuf.Timestamp getCreateTime();
/**
* <code>.google.protobuf.Timestamp create_time = 4;.</code>
*/
com.google.protobuf.TimestampOrBuilder getCreateTimeOrBuilder();
/**
* <code>string version = 5;.</code>
*/
String getVersion();
/**
* <code>string version = 5;.</code>
*/
com.google.protobuf.ByteString getVersionBytes();
/**
* <code>map&lt;string, string&gt; labels = 6;.</code>
*/
int getLabelsCount();
/**
* <code>map&lt;string, string&gt; labels = 6;.</code>
*/
boolean containsLabels(String key);
/**
* Use {@link #getLabelsMap()} instead.
*/
@Deprecated
java.util.Map<String, String> getLabels();
/**
* <code>map&lt;string, string&gt; labels = 6;.</code>
*/
java.util.Map<String, String> getLabelsMap();
/**
* <code>map&lt;string, string&gt; labels = 6;.</code>
*/
String getLabelsOrDefault(String key, String defaultValue);
/**
* <code>map&lt;string, string&gt; labels = 6;.</code>
*/
String getLabelsOrThrow(String key);
}

View File

@ -1,979 +0,0 @@
/*
* 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.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: nacos_grpc_service.proto
package com.alibaba.nacos.api.grpc;
/**
* Protobuf type {@code GrpcRequest}
*/
public final class GrpcRequest extends
com.google.protobuf.GeneratedMessageV3 implements
// @@protoc_insertion_point(message_implements:GrpcRequest)
GrpcRequestOrBuilder {
// Use GrpcRequest.newBuilder() to construct.
private GrpcRequest(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private GrpcRequest() {
type_ = "";
}
@Override
public final com.google.protobuf.UnknownFieldSet
getUnknownFields() {
return com.google.protobuf.UnknownFieldSet.getDefaultInstance();
}
private GrpcRequest(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
this();
int mutable_bitField0_ = 0;
try {
boolean done = false;
while (!done) {
int tag = input.readTag();
switch (tag) {
case 0:
done = true;
break;
default: {
if (!input.skipField(tag)) {
done = true;
}
break;
}
case 10: {
GrpcMetadata.Builder subBuilder = null;
if (metadata_ != null) {
subBuilder = metadata_.toBuilder();
}
metadata_ = input.readMessage(GrpcMetadata.parser(), extensionRegistry);
if (subBuilder != null) {
subBuilder.mergeFrom(metadata_);
metadata_ = subBuilder.buildPartial();
}
break;
}
case 18: {
String s = input.readStringRequireUtf8();
type_ = s;
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;
}
}
}
} 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 {
makeExtensionsImmutable();
}
}
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return NacosGrpcService.internal_static_GrpcRequest_descriptor;
}
protected FieldAccessorTable
internalGetFieldAccessorTable() {
return NacosGrpcService.internal_static_GrpcRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
GrpcRequest.class, GrpcRequest.Builder.class);
}
public static final int TYPE_FIELD_NUMBER = 2;
private volatile Object type_;
/**
* <code>string type = 2;</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 = 2;</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 METADATA_FIELD_NUMBER = 1;
private GrpcMetadata metadata_;
/**
* <pre>
* Common metadata describing the resource.
* </pre>
*
* <code>.GrpcMetadata metadata = 1;</code>
*/
public boolean hasMetadata() {
return metadata_ != null;
}
/**
* <pre>
* Common metadata describing the resource.
* </pre>
*
* <code>.GrpcMetadata metadata = 1;</code>
*/
public GrpcMetadata getMetadata() {
return metadata_ == null ? GrpcMetadata.getDefaultInstance() : metadata_;
}
/**
* <pre>
* Common metadata describing the resource.
* </pre>
*
* <code>.GrpcMetadata metadata = 1;</code>
*/
public GrpcMetadataOrBuilder getMetadataOrBuilder() {
return getMetadata();
}
public static final int BODY_FIELD_NUMBER = 3;
private com.google.protobuf.Any body_;
/**
* <pre>
* The primary payload for the resource.
* </pre>
*
* <code>.google.protobuf.Any body = 3;</code>
*/
public boolean hasBody() {
return body_ != null;
}
/**
* <pre>
* The primary payload for the resource.
* </pre>
*
* <code>.google.protobuf.Any body = 3;</code>
*/
public com.google.protobuf.Any getBody() {
return body_ == null ? com.google.protobuf.Any.getDefaultInstance() : body_;
}
/**
* <pre>
* The primary payload for the resource.
* </pre>
*
* <code>.google.protobuf.Any body = 3;</code>
*/
public com.google.protobuf.AnyOrBuilder getBodyOrBuilder() {
return getBody();
}
private byte memoizedIsInitialized = -1;
public final boolean isInitialized() {
byte isInitialized = memoizedIsInitialized;
if (isInitialized == 1) return true;
if (isInitialized == 0) return false;
memoizedIsInitialized = 1;
return true;
}
public void writeTo(com.google.protobuf.CodedOutputStream output)
throws java.io.IOException {
if (metadata_ != null) {
output.writeMessage(1, getMetadata());
}
if (!getTypeBytes().isEmpty()) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 2, type_);
}
if (body_ != null) {
output.writeMessage(3, getBody());
}
}
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (metadata_ != null) {
size += com.google.protobuf.CodedOutputStream
.computeMessageSize(1, getMetadata());
}
if (!getTypeBytes().isEmpty()) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, type_);
}
if (body_ != null) {
size += com.google.protobuf.CodedOutputStream
.computeMessageSize(3, getBody());
}
memoizedSize = size;
return size;
}
private static final long serialVersionUID = 0L;
@Override
public boolean equals(final Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof GrpcRequest)) {
return super.equals(obj);
}
GrpcRequest other = (GrpcRequest) obj;
boolean result = true;
result = result && getType()
.equals(other.getType());
result = result && (hasMetadata() == other.hasMetadata());
if (hasMetadata()) {
result = result && getMetadata()
.equals(other.getMetadata());
}
result = result && (hasBody() == other.hasBody());
if (hasBody()) {
result = result && getBody()
.equals(other.getBody());
}
return result;
}
@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();
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 GrpcRequest parseFrom(
java.nio.ByteBuffer data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static GrpcRequest parseFrom(
java.nio.ByteBuffer data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static GrpcRequest parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static GrpcRequest parseFrom(
com.google.protobuf.ByteString data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static GrpcRequest parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static GrpcRequest parseFrom(
byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static GrpcRequest parseFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static GrpcRequest 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 GrpcRequest parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input);
}
public static GrpcRequest 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 GrpcRequest parseFrom(
com.google.protobuf.CodedInputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static GrpcRequest parseFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input, extensionRegistry);
}
public Builder newBuilderForType() { return newBuilder(); }
public static Builder newBuilder() {
return DEFAULT_INSTANCE.toBuilder();
}
public static Builder newBuilder(GrpcRequest prototype) {
return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
}
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 GrpcRequest}
*/
public static final class Builder extends
com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
// @@protoc_insertion_point(builder_implements:GrpcRequest)
GrpcRequestOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return NacosGrpcService.internal_static_GrpcRequest_descriptor;
}
protected FieldAccessorTable
internalGetFieldAccessorTable() {
return NacosGrpcService.internal_static_GrpcRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
GrpcRequest.class, GrpcRequest.Builder.class);
}
// Construct using com.alibaba.nacos.api.grpc.GrpcRequest.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private Builder(
BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessageV3
.alwaysUseFieldBuilders) {
}
}
public Builder clear() {
super.clear();
type_ = "";
if (metadataBuilder_ == null) {
metadata_ = null;
} else {
metadata_ = null;
metadataBuilder_ = null;
}
if (bodyBuilder_ == null) {
body_ = null;
} else {
body_ = null;
bodyBuilder_ = null;
}
return this;
}
public com.google.protobuf.Descriptors.Descriptor
getDescriptorForType() {
return NacosGrpcService.internal_static_GrpcRequest_descriptor;
}
public GrpcRequest getDefaultInstanceForType() {
return GrpcRequest.getDefaultInstance();
}
public GrpcRequest build() {
GrpcRequest result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
public GrpcRequest buildPartial() {
GrpcRequest result = new GrpcRequest(this);
result.type_ = type_;
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;
}
public Builder clone() {
return (Builder) super.clone();
}
public Builder setField(
com.google.protobuf.Descriptors.FieldDescriptor field,
Object value) {
return (Builder) super.setField(field, value);
}
public Builder clearField(
com.google.protobuf.Descriptors.FieldDescriptor field) {
return (Builder) super.clearField(field);
}
public Builder clearOneof(
com.google.protobuf.Descriptors.OneofDescriptor oneof) {
return (Builder) super.clearOneof(oneof);
}
public Builder setRepeatedField(
com.google.protobuf.Descriptors.FieldDescriptor field,
int index, Object value) {
return (Builder) super.setRepeatedField(field, index, value);
}
public Builder addRepeatedField(
com.google.protobuf.Descriptors.FieldDescriptor field,
Object value) {
return (Builder) super.addRepeatedField(field, value);
}
public Builder mergeFrom(com.google.protobuf.Message other) {
if (other instanceof GrpcRequest) {
return mergeFrom((GrpcRequest)other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(GrpcRequest other) {
if (other == GrpcRequest.getDefaultInstance()) return this;
if (!other.getType().isEmpty()) {
type_ = other.type_;
onChanged();
}
if (other.hasMetadata()) {
mergeMetadata(other.getMetadata());
}
if (other.hasBody()) {
mergeBody(other.getBody());
}
onChanged();
return this;
}
public final boolean isInitialized() {
return true;
}
public Builder mergeFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
GrpcRequest parsedMessage = null;
try {
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
parsedMessage = (GrpcRequest) e.getUnfinishedMessage();
throw e.unwrapIOException();
} finally {
if (parsedMessage != null) {
mergeFrom(parsedMessage);
}
}
return this;
}
private Object type_ = "";
/**
* <code>string type = 2;</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 = 2;</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 = 2;</code>
*/
public Builder setType(
String value) {
if (value == null) {
throw new NullPointerException();
}
type_ = value;
onChanged();
return this;
}
/**
* <code>string type = 2;</code>
*/
public Builder clearType() {
type_ = getDefaultInstance().getType();
onChanged();
return this;
}
/**
* <code>string type = 2;</code>
*/
public Builder setTypeBytes(
com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
type_ = value;
onChanged();
return this;
}
private GrpcMetadata metadata_ = null;
private com.google.protobuf.SingleFieldBuilderV3<
GrpcMetadata, GrpcMetadata.Builder, GrpcMetadataOrBuilder> metadataBuilder_;
/**
* <pre>
* Common metadata describing the resource.
* </pre>
*
* <code>.GrpcMetadata metadata = 1;</code>
*/
public boolean hasMetadata() {
return metadataBuilder_ != null || metadata_ != null;
}
/**
* <pre>
* Common metadata describing the resource.
* </pre>
*
* <code>.GrpcMetadata metadata = 1;</code>
*/
public GrpcMetadata getMetadata() {
if (metadataBuilder_ == null) {
return metadata_ == null ? GrpcMetadata.getDefaultInstance() : metadata_;
} else {
return metadataBuilder_.getMessage();
}
}
/**
* <pre>
* Common metadata describing the resource.
* </pre>
*
* <code>.GrpcMetadata metadata = 1;</code>
*/
public Builder setMetadata(GrpcMetadata value) {
if (metadataBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
metadata_ = value;
onChanged();
} else {
metadataBuilder_.setMessage(value);
}
return this;
}
/**
* <pre>
* Common metadata describing the resource.
* </pre>
*
* <code>.GrpcMetadata metadata = 1;</code>
*/
public Builder setMetadata(
GrpcMetadata.Builder builderForValue) {
if (metadataBuilder_ == null) {
metadata_ = builderForValue.build();
onChanged();
} else {
metadataBuilder_.setMessage(builderForValue.build());
}
return this;
}
/**
* <pre>
* Common metadata describing the resource.
* </pre>
*
* <code>.GrpcMetadata metadata = 1;</code>
*/
public Builder mergeMetadata(GrpcMetadata value) {
if (metadataBuilder_ == null) {
if (metadata_ != null) {
metadata_ =
GrpcMetadata.newBuilder(metadata_).mergeFrom(value).buildPartial();
} else {
metadata_ = value;
}
onChanged();
} else {
metadataBuilder_.mergeFrom(value);
}
return this;
}
/**
* <pre>
* Common metadata describing the resource.
* </pre>
*
* <code>.GrpcMetadata metadata = 1;</code>
*/
public Builder clearMetadata() {
if (metadataBuilder_ == null) {
metadata_ = null;
onChanged();
} else {
metadata_ = null;
metadataBuilder_ = null;
}
return this;
}
/**
* <pre>
* Common metadata describing the resource.
* </pre>
*
* <code>.GrpcMetadata metadata = 1;</code>
*/
public GrpcMetadata.Builder getMetadataBuilder() {
onChanged();
return getMetadataFieldBuilder().getBuilder();
}
/**
* <pre>
* Common metadata describing the resource.
* </pre>
*
* <code>.GrpcMetadata metadata = 1;</code>
*/
public GrpcMetadataOrBuilder getMetadataOrBuilder() {
if (metadataBuilder_ != null) {
return metadataBuilder_.getMessageOrBuilder();
} else {
return metadata_ == null ?
GrpcMetadata.getDefaultInstance() : metadata_;
}
}
/**
* <pre>
* Common metadata describing the resource.
* </pre>
*
* <code>.GrpcMetadata metadata = 1;</code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
GrpcMetadata, GrpcMetadata.Builder, GrpcMetadataOrBuilder>
getMetadataFieldBuilder() {
if (metadataBuilder_ == null) {
metadataBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
GrpcMetadata, GrpcMetadata.Builder, GrpcMetadataOrBuilder>(
getMetadata(),
getParentForChildren(),
isClean());
metadata_ = null;
}
return metadataBuilder_;
}
private com.google.protobuf.Any body_ = null;
private com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder> bodyBuilder_;
/**
* <pre>
* The primary payload for the resource.
* </pre>
*
* <code>.google.protobuf.Any body = 3;</code>
*/
public boolean hasBody() {
return bodyBuilder_ != null || body_ != null;
}
/**
* <pre>
* The primary payload for the resource.
* </pre>
*
* <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();
}
}
/**
* <pre>
* The primary payload for the resource.
* </pre>
*
* <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;
}
/**
* <pre>
* The primary payload for the resource.
* </pre>
*
* <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;
}
/**
* <pre>
* The primary payload for the resource.
* </pre>
*
* <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;
}
/**
* <pre>
* The primary payload for the resource.
* </pre>
*
* <code>.google.protobuf.Any body = 3;</code>
*/
public Builder clearBody() {
if (bodyBuilder_ == null) {
body_ = null;
onChanged();
} else {
body_ = null;
bodyBuilder_ = null;
}
return this;
}
/**
* <pre>
* The primary payload for the resource.
* </pre>
*
* <code>.google.protobuf.Any body = 3;</code>
*/
public com.google.protobuf.Any.Builder getBodyBuilder() {
onChanged();
return getBodyFieldBuilder().getBuilder();
}
/**
* <pre>
* The primary payload for the resource.
* </pre>
*
* <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_;
}
}
/**
* <pre>
* The primary payload for the resource.
* </pre>
*
* <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_;
}
public final Builder setUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return this;
}
public final Builder mergeUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return this;
}
// @@protoc_insertion_point(builder_scope:GrpcRequest)
}
// @@protoc_insertion_point(class_scope:GrpcRequest)
private static final GrpcRequest DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new GrpcRequest();
}
public static GrpcRequest getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<GrpcRequest>
PARSER = new com.google.protobuf.AbstractParser<GrpcRequest>() {
public GrpcRequest parsePartialFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return new GrpcRequest(input, extensionRegistry);
}
};
public static com.google.protobuf.Parser<GrpcRequest> parser() {
return PARSER;
}
@Override
public com.google.protobuf.Parser<GrpcRequest> getParserForType() {
return PARSER;
}
public GrpcRequest getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}

View File

@ -1,85 +0,0 @@
/*
* 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.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: nacos_grpc_service.proto
package com.alibaba.nacos.api.grpc;
public interface GrpcRequestOrBuilder extends
// @@protoc_insertion_point(interface_extends:GrpcRequest)
com.google.protobuf.MessageOrBuilder {
/**
* <code>string type = 2;</code>
*/
String getType();
/**
* <code>string type = 2;</code>
*/
com.google.protobuf.ByteString
getTypeBytes();
/**
* <pre>
* Common metadata describing the resource.
* </pre>
*
* <code>.GrpcMetadata metadata = 1;</code>
*/
boolean hasMetadata();
/**
* <pre>
* Common metadata describing the resource.
* </pre>
*
* <code>.GrpcMetadata metadata = 1;</code>
*/
GrpcMetadata getMetadata();
/**
* <pre>
* Common metadata describing the resource.
* </pre>
*
* <code>.GrpcMetadata metadata = 1;</code>
*/
GrpcMetadataOrBuilder getMetadataOrBuilder();
/**
* <pre>
* The primary payload for the resource.
* </pre>
*
* <code>.google.protobuf.Any body = 3;</code>
*/
boolean hasBody();
/**
* <pre>
* The primary payload for the resource.
* </pre>
*
* <code>.google.protobuf.Any body = 3;</code>
*/
com.google.protobuf.Any getBody();
/**
* <pre>
* The primary payload for the resource.
* </pre>
*
* <code>.google.protobuf.Any body = 3;</code>
*/
com.google.protobuf.AnyOrBuilder getBodyOrBuilder();
}

View File

@ -1,799 +0,0 @@
/*
* 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.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: nacos_grpc_service.proto
package com.alibaba.nacos.api.grpc;
/**
* Protobuf type {@code GrpcResponse}
*/
public final class GrpcResponse extends com.google.protobuf.GeneratedMessageV3 implements
// @@protoc_insertion_point(message_implements:GrpcResponse)
GrpcResponseOrBuilder {
// Use GrpcResponse.newBuilder() to construct.
private GrpcResponse(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private GrpcResponse() {
code_ = 0;
type_ = "";
}
@Override
public final com.google.protobuf.UnknownFieldSet getUnknownFields() {
return com.google.protobuf.UnknownFieldSet.getDefaultInstance();
}
private GrpcResponse(com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
this();
int mutable_bitField0_ = 0;
try {
boolean done = false;
while (!done) {
int tag = input.readTag();
switch (tag) {
case 0:
done = true;
break;
default: {
if (!input.skipField(tag)) {
done = true;
}
break;
}
case 8: {
code_ = input.readInt32();
break;
}
case 18: {
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;
}
case 26: {
String s = input.readStringRequireUtf8();
type_ = s;
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 {
makeExtensionsImmutable();
}
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return NacosGrpcService.internal_static_GrpcResponse_descriptor;
}
protected FieldAccessorTable internalGetFieldAccessorTable() {
return NacosGrpcService.internal_static_GrpcResponse_fieldAccessorTable
.ensureFieldAccessorsInitialized(GrpcResponse.class, GrpcResponse.Builder.class);
}
public static final int CODE_FIELD_NUMBER = 1;
private int code_;
/**
* <code>int32 code = 1;</code>
*/
public int getCode() {
return code_;
}
public static final int BODY_FIELD_NUMBER = 2;
private com.google.protobuf.Any body_;
/**
* <pre>
* reponse body
* </pre>
*
* <code>.google.protobuf.Any body = 2;</code>
*/
public boolean hasBody() {
return body_ != null;
}
/**
* <pre>
* reponse body
* </pre>
*
* <code>.google.protobuf.Any body = 2;</code>
*/
public com.google.protobuf.Any getBody() {
return body_ == null ? com.google.protobuf.Any.getDefaultInstance() : body_;
}
/**
* <pre>
* reponse body
* </pre>
*
* <code>.google.protobuf.Any body = 2;</code>
*/
public com.google.protobuf.AnyOrBuilder getBodyOrBuilder() {
return getBody();
}
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;
}
}
private byte memoizedIsInitialized = -1;
public final boolean isInitialized() {
byte isInitialized = memoizedIsInitialized;
if (isInitialized == 1) {
return true;
}
if (isInitialized == 0) {
return false;
}
memoizedIsInitialized = 1;
return true;
}
public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException {
if (code_ != 0) {
output.writeInt32(1, code_);
}
if (body_ != null) {
output.writeMessage(2, getBody());
}
if (!getTypeBytes().isEmpty()) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 3, type_);
}
}
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) {
return size;
}
size = 0;
if (code_ != 0) {
size += com.google.protobuf.CodedOutputStream.computeInt32Size(1, code_);
}
if (body_ != null) {
size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getBody());
}
if (!getTypeBytes().isEmpty()) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, type_);
}
memoizedSize = size;
return size;
}
private static final long serialVersionUID = 0L;
@Override
public boolean equals(final Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof GrpcResponse)) {
return super.equals(obj);
}
GrpcResponse other = (GrpcResponse) obj;
boolean result = true;
result = result && (getCode() == other.getCode());
result = result && (hasBody() == other.hasBody());
if (hasBody()) {
result = result && getBody().equals(other.getBody());
}
result = result && getType().equals(other.getType());
return result;
}
@Override
public int hashCode() {
if (memoizedHashCode != 0) {
return memoizedHashCode;
}
int hash = 41;
hash = (19 * hash) + getDescriptor().hashCode();
hash = (37 * hash) + CODE_FIELD_NUMBER;
hash = (53 * hash) + getCode();
if (hasBody()) {
hash = (37 * hash) + BODY_FIELD_NUMBER;
hash = (53 * hash) + getBody().hashCode();
}
hash = (37 * hash) + TYPE_FIELD_NUMBER;
hash = (53 * hash) + getType().hashCode();
hash = (29 * hash) + unknownFields.hashCode();
memoizedHashCode = hash;
return hash;
}
public static GrpcResponse parseFrom(java.nio.ByteBuffer data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static GrpcResponse parseFrom(java.nio.ByteBuffer data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static GrpcResponse parseFrom(com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static GrpcResponse parseFrom(com.google.protobuf.ByteString data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static GrpcResponse parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static GrpcResponse parseFrom(byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static GrpcResponse parseFrom(java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static GrpcResponse 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 GrpcResponse parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static GrpcResponse 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 GrpcResponse parseFrom(com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static GrpcResponse parseFrom(com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input, extensionRegistry);
}
public Builder newBuilderForType() {
return newBuilder();
}
public static Builder newBuilder() {
return DEFAULT_INSTANCE.toBuilder();
}
public static Builder newBuilder(GrpcResponse prototype) {
return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
}
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 GrpcResponse}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
// @@protoc_insertion_point(builder_implements:GrpcResponse)
GrpcResponseOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return NacosGrpcService.internal_static_GrpcResponse_descriptor;
}
protected FieldAccessorTable internalGetFieldAccessorTable() {
return NacosGrpcService.internal_static_GrpcResponse_fieldAccessorTable
.ensureFieldAccessorsInitialized(GrpcResponse.class, GrpcResponse.Builder.class);
}
// Construct using com.alibaba.nacos.api.grpc.GrpcResponse.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private Builder(BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {
}
}
public Builder clear() {
super.clear();
code_ = 0;
if (bodyBuilder_ == null) {
body_ = null;
} else {
body_ = null;
bodyBuilder_ = null;
}
type_ = "";
return this;
}
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return NacosGrpcService.internal_static_GrpcResponse_descriptor;
}
public GrpcResponse getDefaultInstanceForType() {
return GrpcResponse.getDefaultInstance();
}
public GrpcResponse build() {
GrpcResponse result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
public GrpcResponse buildPartial() {
GrpcResponse result = new GrpcResponse(this);
result.code_ = code_;
if (bodyBuilder_ == null) {
result.body_ = body_;
} else {
result.body_ = bodyBuilder_.build();
}
result.type_ = type_;
onBuilt();
return result;
}
public Builder clone() {
return (Builder) super.clone();
}
public Builder setField(com.google.protobuf.Descriptors.FieldDescriptor field, Object value) {
return (Builder) super.setField(field, value);
}
public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) {
return (Builder) super.clearField(field);
}
public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) {
return (Builder) super.clearOneof(oneof);
}
public Builder setRepeatedField(com.google.protobuf.Descriptors.FieldDescriptor field, int index,
Object value) {
return (Builder) super.setRepeatedField(field, index, value);
}
public Builder addRepeatedField(com.google.protobuf.Descriptors.FieldDescriptor field, Object value) {
return (Builder) super.addRepeatedField(field, value);
}
public Builder mergeFrom(com.google.protobuf.Message other) {
if (other instanceof GrpcResponse) {
return mergeFrom((GrpcResponse) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(GrpcResponse other) {
if (other == GrpcResponse.getDefaultInstance()) {
return this;
}
if (other.getCode() != 0) {
setCode(other.getCode());
}
if (other.hasBody()) {
mergeBody(other.getBody());
}
if (!other.getType().isEmpty()) {
type_ = other.type_;
onChanged();
}
onChanged();
return this;
}
public final boolean isInitialized() {
return true;
}
public Builder mergeFrom(com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException {
GrpcResponse parsedMessage = null;
try {
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
parsedMessage = (GrpcResponse) e.getUnfinishedMessage();
throw e.unwrapIOException();
} finally {
if (parsedMessage != null) {
mergeFrom(parsedMessage);
}
}
return this;
}
private int code_;
/**
* <code>int32 code = 1;</code>
*/
public int getCode() {
return code_;
}
/**
* <code>int32 code = 1;</code>
*/
public Builder setCode(int value) {
code_ = value;
onChanged();
return this;
}
/**
* <code>int32 code = 1;</code>
*/
public Builder clearCode() {
code_ = 0;
onChanged();
return this;
}
private com.google.protobuf.Any body_ = null;
private com.google.protobuf.SingleFieldBuilderV3<com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder> bodyBuilder_;
/**
* <pre>
* reponse body
* </pre>
*
* <code>.google.protobuf.Any body = 2;</code>
*/
public boolean hasBody() {
return bodyBuilder_ != null || body_ != null;
}
/**
* <pre>
* reponse body
* </pre>
*
* <code>.google.protobuf.Any body = 2;</code>
*/
public com.google.protobuf.Any getBody() {
if (bodyBuilder_ == null) {
return body_ == null ? com.google.protobuf.Any.getDefaultInstance() : body_;
} else {
return bodyBuilder_.getMessage();
}
}
/**
* <pre>
* reponse body
* </pre>
*
* <code>.google.protobuf.Any body = 2;</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;
}
/**
* <pre>
* reponse body
* </pre>
*
* <code>.google.protobuf.Any body = 2;</code>
*/
public Builder setBody(com.google.protobuf.Any.Builder builderForValue) {
if (bodyBuilder_ == null) {
body_ = builderForValue.build();
onChanged();
} else {
bodyBuilder_.setMessage(builderForValue.build());
}
return this;
}
/**
* <pre>
* reponse body
* </pre>
*
* <code>.google.protobuf.Any body = 2;</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;
}
/**
* <pre>
* reponse body
* </pre>
*
* <code>.google.protobuf.Any body = 2;</code>
*/
public Builder clearBody() {
if (bodyBuilder_ == null) {
body_ = null;
onChanged();
} else {
body_ = null;
bodyBuilder_ = null;
}
return this;
}
/**
* <pre>
* reponse body
* </pre>
*
* <code>.google.protobuf.Any body = 2;</code>
*/
public com.google.protobuf.Any.Builder getBodyBuilder() {
onChanged();
return getBodyFieldBuilder().getBuilder();
}
/**
* <pre>
* reponse body
* </pre>
*
* <code>.google.protobuf.Any body = 2;</code>
*/
public com.google.protobuf.AnyOrBuilder getBodyOrBuilder() {
if (bodyBuilder_ != null) {
return bodyBuilder_.getMessageOrBuilder();
} else {
return body_ == null ? com.google.protobuf.Any.getDefaultInstance() : body_;
}
}
/**
* <pre>
* reponse body
* </pre>
*
* <code>.google.protobuf.Any body = 2;</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_;
}
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;
}
public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) {
return this;
}
public final Builder mergeUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) {
return this;
}
// @@protoc_insertion_point(builder_scope:GrpcResponse)
}
// @@protoc_insertion_point(class_scope:GrpcResponse)
private static final GrpcResponse DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new GrpcResponse();
}
public static GrpcResponse getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<GrpcResponse> PARSER = new com.google.protobuf.AbstractParser<GrpcResponse>() {
public GrpcResponse parsePartialFrom(com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return new GrpcResponse(input, extensionRegistry);
}
};
public static com.google.protobuf.Parser<GrpcResponse> parser() {
return PARSER;
}
@Override
public com.google.protobuf.Parser<GrpcResponse> getParserForType() {
return PARSER;
}
public GrpcResponse getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}

View File

@ -1,67 +0,0 @@
/*
* 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.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: nacos_grpc_service.proto
package com.alibaba.nacos.api.grpc;
public interface GrpcResponseOrBuilder extends
// @@protoc_insertion_point(interface_extends:GrpcResponse)
com.google.protobuf.MessageOrBuilder {
/**
* <code>int32 code = 1;</code>
*/
int getCode();
/**
* <pre>
* reponse body
* </pre>
*
* <code>.google.protobuf.Any body = 2;</code>
*/
boolean hasBody();
/**
* <pre>
* reponse body
* </pre>
*
* <code>.google.protobuf.Any body = 2;</code>
*/
com.google.protobuf.Any getBody();
/**
* <pre>
* reponse body
* </pre>
*
* <code>.google.protobuf.Any body = 2;</code>
*/
com.google.protobuf.AnyOrBuilder getBodyOrBuilder();
/**
* <code>string type = 3;</code>
*/
String getType();
/**
* <code>string type = 3;</code>
*/
com.google.protobuf.ByteString getTypeBytes();
}

View File

@ -1,121 +0,0 @@
/*
* 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.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: nacos_grpc_service.proto
package com.alibaba.nacos.api.grpc;
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_GrpcMetadata_descriptor;
static final
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internal_static_GrpcMetadata_fieldAccessorTable;
static final com.google.protobuf.Descriptors.Descriptor
internal_static_GrpcMetadata_LabelsEntry_descriptor;
static final
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internal_static_GrpcMetadata_LabelsEntry_fieldAccessorTable;
static final com.google.protobuf.Descriptors.Descriptor
internal_static_GrpcRequest_descriptor;
static final
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internal_static_GrpcRequest_fieldAccessorTable;
static final com.google.protobuf.Descriptors.Descriptor
internal_static_GrpcResponse_descriptor;
static final
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internal_static_GrpcResponse_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\"\342\001\n\014GrpcMetadata\022\014\n\004name\030\001 \001(\t\022\021\n" +
"\tclient_ip\030\002 \001(\t\022\025\n\rconnection_id\030\003 \001(\t\022" +
"/\n\013create_time\030\004 \001(\0132\032.google.protobuf.T" +
"imestamp\022\017\n\007version\030\005 \001(\t\022)\n\006labels\030\006 \003(" +
"\0132\031.GrpcMetadata.LabelsEntry\032-\n\013LabelsEn" +
"try\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001\"`\n\013G" +
"rpcRequest\022\014\n\004type\030\002 \001(\t\022\037\n\010metadata\030\001 \001" +
"(\0132\r.GrpcMetadata\022\"\n\004body\030\003 \001(\0132\024.google",
".protobuf.Any\"N\n\014GrpcResponse\022\014\n\004code\030\001 "
+ "\001(\005\022\"\n\004body\030\002 \001(\0132\024.google.protobuf.Any\022"
+ "\014\n\004type\030\003 \001(\t2A\n\rRequestStream\0220\n\rreques"
+ "tStream\022\014.GrpcRequest\032\r.GrpcResponse\"\0000\001"
+ "23\n\007Request\022(\n\007request\022\014.GrpcRequest\032\r.G"
+ "rpcResponse\"\000B\036\n\032com.alibaba.nacos.api.g" + "rpcP\001b\006proto3"
};
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() {
public com.google.protobuf.ExtensionRegistry assignDescriptors(
com.google.protobuf.Descriptors.FileDescriptor root) {
descriptor = root;
return null;
}
};
com.google.protobuf.Descriptors.FileDescriptor
.internalBuildGeneratedFileFrom(descriptorData,
new com.google.protobuf.Descriptors.FileDescriptor[] {
com.google.protobuf.AnyProto.getDescriptor(),
com.google.protobuf.TimestampProto.getDescriptor(),
}, assigner);
internal_static_GrpcMetadata_descriptor =
getDescriptor().getMessageTypes().get(0);
internal_static_GrpcMetadata_fieldAccessorTable = new
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
internal_static_GrpcMetadata_descriptor,
new String[] { "Name", "ClientIp", "ConnectionId", "CreateTime", "Version", "Labels", });
internal_static_GrpcMetadata_LabelsEntry_descriptor =
internal_static_GrpcMetadata_descriptor.getNestedTypes().get(0);
internal_static_GrpcMetadata_LabelsEntry_fieldAccessorTable = new
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
internal_static_GrpcMetadata_LabelsEntry_descriptor,
new String[] { "Key", "Value", });
internal_static_GrpcRequest_descriptor =
getDescriptor().getMessageTypes().get(1);
internal_static_GrpcRequest_fieldAccessorTable = new
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
internal_static_GrpcRequest_descriptor,
new String[] { "Type", "Metadata", "Body", });
internal_static_GrpcResponse_descriptor =
getDescriptor().getMessageTypes().get(2);
internal_static_GrpcResponse_fieldAccessorTable = new
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
internal_static_GrpcResponse_descriptor, new String[] {"Code", "Body", "Type",});
com.google.protobuf.AnyProto.getDescriptor();
com.google.protobuf.TimestampProto.getDescriptor();
}
// @@protoc_insertion_point(outer_class_scope)
}

View File

@ -1,306 +0,0 @@
/*
* 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;
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.20.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<GrpcRequest,
GrpcResponse> getRequestMethod;
@io.grpc.stub.annotations.RpcMethod(
fullMethodName = SERVICE_NAME + '/' + "request",
requestType = GrpcRequest.class,
responseType = GrpcResponse.class,
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
public static io.grpc.MethodDescriptor<GrpcRequest,
GrpcResponse> getRequestMethod() {
io.grpc.MethodDescriptor<GrpcRequest, GrpcResponse> getRequestMethod;
if ((getRequestMethod = RequestGrpc.getRequestMethod) == null) {
synchronized (RequestGrpc.class) {
if ((getRequestMethod = RequestGrpc.getRequestMethod) == null) {
RequestGrpc.getRequestMethod = getRequestMethod =
io.grpc.MethodDescriptor.<GrpcRequest, GrpcResponse>newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
.setFullMethodName(generateFullMethodName(
"Request", "request"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
GrpcRequest.getDefaultInstance()))
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
GrpcResponse.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(GrpcRequest request, io.grpc.stub.StreamObserver<GrpcResponse> responseObserver) {
asyncUnimplementedUnaryCall(getRequestMethod(), responseObserver);
}
@Override public final io.grpc.ServerServiceDefinition bindService() {
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
.addMethod(
getRequestMethod(),
asyncUnaryCall(
new MethodHandlers<
GrpcRequest,
GrpcResponse>(
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(GrpcRequest request, io.grpc.stub.StreamObserver<GrpcResponse> 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 GrpcResponse request(GrpcRequest 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<GrpcResponse> request(
GrpcRequest 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((GrpcRequest) request,
(io.grpc.stub.StreamObserver<GrpcResponse>) 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 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

@ -1,296 +0,0 @@
/*
* 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;
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.20.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<GrpcRequest,
GrpcResponse> getRequestStreamMethod;
@io.grpc.stub.annotations.RpcMethod(
fullMethodName = SERVICE_NAME + '/' + "requestStream",
requestType = GrpcRequest.class,
responseType = GrpcResponse.class,
methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING)
public static io.grpc.MethodDescriptor<GrpcRequest,
GrpcResponse> getRequestStreamMethod() {
io.grpc.MethodDescriptor<GrpcRequest, GrpcResponse> getRequestStreamMethod;
if ((getRequestStreamMethod = RequestStreamGrpc.getRequestStreamMethod) == null) {
synchronized (RequestStreamGrpc.class) {
if ((getRequestStreamMethod = RequestStreamGrpc.getRequestStreamMethod) == null) {
RequestStreamGrpc.getRequestStreamMethod = getRequestStreamMethod =
io.grpc.MethodDescriptor.<GrpcRequest, GrpcResponse>newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING)
.setFullMethodName(generateFullMethodName(
"RequestStream", "requestStream"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
GrpcRequest.getDefaultInstance()))
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
GrpcResponse.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(GrpcRequest request, io.grpc.stub.StreamObserver<GrpcResponse> responseObserver) {
asyncUnimplementedUnaryCall(getRequestStreamMethod(), responseObserver);
}
@Override public final io.grpc.ServerServiceDefinition bindService() {
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
.addMethod(
getRequestStreamMethod(),
asyncServerStreamingCall(
new MethodHandlers<
GrpcRequest,
GrpcResponse>(
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(GrpcRequest request, io.grpc.stub.StreamObserver<GrpcResponse> 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<GrpcResponse> requestStream(
GrpcRequest 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((GrpcRequest) request,
(io.grpc.stub.StreamObserver<GrpcResponse>) 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 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

@ -17,7 +17,7 @@
package com.alibaba.nacos.api.remote.connection; package com.alibaba.nacos.api.remote.connection;
/** /**
* ConnectionType * ConnectionType.
* @author liuzunfei * @author liuzunfei
* @version $Id: ConnectionType.java, v 0.1 2020年07月13日 7:15 PM liuzunfei Exp $ * @version $Id: ConnectionType.java, v 0.1 2020年07月13日 7:15 PM liuzunfei Exp $
*/ */

View File

@ -13,10 +13,11 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.alibaba.nacos.api.remote.request; package com.alibaba.nacos.api.remote.request;
/** /**
* HeartBeatRequest.
* @author liuzunfei * @author liuzunfei
* @version $Id: HeartBeatRequest.java, v 0.1 2020年07月14日 11:38 AM liuzunfei Exp $ * @version $Id: HeartBeatRequest.java, v 0.1 2020年07月14日 11:38 AM liuzunfei Exp $
*/ */

View File

@ -13,14 +13,17 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.alibaba.nacos.api.remote.request; package com.alibaba.nacos.api.remote.request;
/** /**
* RequestTypeConstants.
*
* @author liuzunfei * @author liuzunfei
* @version $Id: RequestTypeConstants.java, v 0.1 2020年07月13日 9:18 PM liuzunfei Exp $ * @version $Id: RequestTypeConstants.java, v 0.1 2020年07月13日 9:18 PM liuzunfei Exp $
*/ */
public class RequestTypeConstants { public class RequestTypeConstants {
public static final String HEART_BEAT="HEART_BEAT"; public static final String HEART_BEAT = "HEART_BEAT";
} }

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.remote.response;
/**
* ServerPushResponse.
*
* @author liuzunfei
* @version $Id: ServerPushResponse.java, v 0.1 2020年07月20日 1:21 PM liuzunfei Exp $
*/
public abstract class ServerPushResponse extends Response {
/**
* unique id for this server response id.
*/
private String responseId;
public ServerPushResponse() {
super();
this.responseId = "todo";
}
/**
* Getter method for property <tt>responseId</tt>.
*
* @return property value of responseId
*/
public String getResponseId() {
return responseId;
}
/**
* Setter method for property <tt>responseId</tt>.
*
* @param responseId value to be assigned to property responseId
*/
public void setResponseId(String responseId) {
this.responseId = responseId;
}
}

View File

@ -217,7 +217,6 @@ public class NacosConfigService implements ConfigService {
} }
} }
private boolean removeConfigInRpc(String tenant, String dataId, String group, String tag) { private boolean removeConfigInRpc(String tenant, String dataId, String group, String tag) {
try { try {

View File

@ -31,7 +31,7 @@ import java.util.Map;
public interface HttpAgent extends Closeable { public interface HttpAgent extends Closeable {
/** /**
* get server list manager * get server list manager.
* @return * @return
*/ */
ServerListManager getServerListManager(); ServerListManager getServerListManager();

View File

@ -92,6 +92,7 @@ public class ClientWorker implements Closeable {
} }
try { try {
rpcClientProxy.listenConfigChange(dataId, group, ""); rpcClientProxy.listenConfigChange(dataId, group, "");
} catch (NacosException e) { } catch (NacosException e) {
LOGGER.error("[{}] [sub-server-error] add listen error , dataId={}, group={}, tenant={}", "rpcClientProxy", LOGGER.error("[{}] [sub-server-error] add listen error , dataId={}, group={}, tenant={}", "rpcClientProxy",
@ -629,6 +630,8 @@ public class ClientWorker implements Closeable {
} }
}); });
rpcClientProxy = new ConfigGrpcClientProxy();
if (ParamUtils.useHttpSwitch()) { if (ParamUtils.useHttpSwitch()) {
this.executor.scheduleWithFixedDelay(new Runnable() { this.executor.scheduleWithFixedDelay(new Runnable() {
@Override @Override
@ -640,10 +643,8 @@ public class ClientWorker implements Closeable {
} }
} }
}, 1L, 10L, TimeUnit.MILLISECONDS); }, 1L, 10L, TimeUnit.MILLISECONDS);
} else { } else {
rpcClientProxy = new ConfigGrpcClientProxy();
rpcClientProxy.initAndStart(new ServerListFactory() { rpcClientProxy.initAndStart(new ServerListFactory() {
@Override @Override
public String genNextServer() { public String genNextServer() {
@ -651,13 +652,13 @@ public class ClientWorker implements Closeable {
serverListManager.refreshCurrentServerAddr(); serverListManager.refreshCurrentServerAddr();
return serverListManager.getCurrentServerAddr(); return serverListManager.getCurrentServerAddr();
} }
@Override @Override
public String getCurrentServer() { public String getCurrentServer() {
return agent.getServerListManager().getCurrentServerAddr(); return agent.getServerListManager().getCurrentServerAddr();
} }
}); });
/* /*
* Register Listen Change Handler * Register Listen Change Handler
*/ */
@ -692,7 +693,7 @@ public class ClientWorker implements Closeable {
} }
}); });
/* /*
* *
*/ */
@ -712,7 +713,7 @@ public class ClientWorker implements Closeable {
} catch (NacosException e) { } catch (NacosException e) {
LOGGER.error("[{}] [listen] {},{},{}", "grpc", cacheData.dataId, cacheData.group, LOGGER.error("[{}] [listen] {},{},{}", "grpc", cacheData.dataId, cacheData.group,
cacheData.tenant, e); cacheData.tenant, e);
} }
} }
} }

View File

@ -120,10 +120,10 @@ public class ConfigGrpcClientProxy {
/** /**
* publish config. * publish config.
* *
* @param dataid * @param dataid dataid
* @param group * @param group group
* @param tenat * @param tenat tenat
* @return * @return push result.
* @throws NacosException throw where publish fail. * @throws NacosException throw where publish fail.
*/ */
public ConfigPubishResponse publishConfig(String dataid, String group, String tenat, String content) public ConfigPubishResponse publishConfig(String dataid, String group, String tenat, String content)
@ -136,10 +136,10 @@ public class ConfigGrpcClientProxy {
/** /**
* remove config. * remove config.
* *
* @param dataid * @param dataid dataid
* @param group * @param group group
* @param tenat * @param tenat tenat
* @return * @return response.
* @throws NacosException throw where publish fail. * @throws NacosException throw where publish fail.
*/ */
public ConfigRemoveResponse removeConfig(String dataid, String group, String tenat, String tag) public ConfigRemoveResponse removeConfig(String dataid, String group, String tenat, String tag)

View File

@ -13,27 +13,28 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.alibaba.nacos.client.remote; package com.alibaba.nacos.client.remote;
/** /**
* Client:ConnectionEventListener.
* @author liuzunfei * @author liuzunfei
* @version $Id: ConnectionEventListener.java, v 0.1 2020年07月14日 10:59 AM liuzunfei Exp $ * @version $Id: ConnectionEventListener.java, v 0.1 2020年07月14日 10:59 AM liuzunfei Exp $
*/ */
public interface ConnectionEventListener { public interface ConnectionEventListener {
/** /**
* * notify when server is connected .
*/ */
public void onConnected(); public void onConnected();
/** /**
* * notify when this client is switch to a new server and is sucessful reconnected .
*/ */
public void onReconnected(); public void onReconnected();
/** /**
* * notify when server is disconnected .
*/ */
public void onDisConnect(); public void onDisConnect();
} }

View File

@ -22,7 +22,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
/** /**
* RpcClientFactory.to support muti client for diffrent client. * RpcClientFactory.to support muti client for diffrent modules of usage.
* *
* @author liuzunfei * @author liuzunfei
* @version $Id: RpcClientFactory.java, v 0.1 2020年07月14日 3:41 PM liuzunfei Exp $ * @version $Id: RpcClientFactory.java, v 0.1 2020年07月14日 3:41 PM liuzunfei Exp $
@ -34,29 +34,16 @@ public class RpcClientFactory {
static Map<String, RpcClient> clientMap = new HashMap<String, RpcClient>(); static Map<String, RpcClient> clientMap = new HashMap<String, RpcClient>();
public static RpcClient getClient(String module) { public static RpcClient getClient(String module) {
String useIndependentClient = System.getProperty("rpc.client.independent"); synchronized (clientMap) {
if ("Y".equalsIgnoreCase(useIndependentClient)) {
if (clientMap.get(module) == null) { if (clientMap.get(module) == null) {
RpcClient moduleClient = new GrpcClient(); RpcClient moduleClient = new GrpcClient();
return clientMap.putIfAbsent(module, moduleClient); clientMap.putIfAbsent(module, moduleClient);
} else {
return clientMap.get(module);
}
} else {
if (sharedClient != null) {
return sharedClient;
} else {
synchronized (RpcClientFactory.class) {
if (sharedClient == null) {
sharedClient = new GrpcClient();
return sharedClient;
} else {
return sharedClient;
}
}
} }
return clientMap.get(module);
} }
} }
} }

View File

@ -17,15 +17,23 @@
package com.alibaba.nacos.client.remote; package com.alibaba.nacos.client.remote;
/** /**
* * server list factory . use to inner client to connecte and switch servers.
* @author liuzunfei * @author liuzunfei
* @version $Id: ServerListFactory.java, v 0.1 2020年07月14日 1:11 PM liuzunfei Exp $ * @version $Id: ServerListFactory.java, v 0.1 2020年07月14日 1:11 PM liuzunfei Exp $
*/ */
public interface ServerListFactory { public interface ServerListFactory {
/**
* switch to a new server and get it.
*
* @return
*/
String genNextServer(); String genNextServer();
/**
* get current server.
* @return
*/
String getCurrentServer(); String getCurrentServer();
} }

View File

@ -48,7 +48,6 @@ import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Consumer; import java.util.function.Consumer;
/** /**
@ -67,8 +66,6 @@ public class GrpcClient extends RpcClient {
protected RequestGrpc.RequestBlockingStub grpcServiceStub; protected RequestGrpc.RequestBlockingStub grpcServiceStub;
private ReentrantLock startClientLock = new ReentrantLock();
ScheduledExecutorService executorService = new ScheduledThreadPoolExecutor(5, new ThreadFactory() { ScheduledExecutorService executorService = new ScheduledThreadPoolExecutor(5, new ThreadFactory() {
@Override @Override
public Thread newThread(Runnable r) { public Thread newThread(Runnable r) {
@ -80,7 +77,7 @@ public class GrpcClient extends RpcClient {
}); });
/** /**
* Reconnect to current server before switch a new server * Reconnect to current server before switch a new server.
*/ */
private static final int MAX_RECONNECT_TIMES = 5; private static final int MAX_RECONNECT_TIMES = 5;
@ -119,14 +116,15 @@ public class GrpcClient extends RpcClient {
// loop until start client success. // loop until start client success.
while (!isRunning()) { while (!isRunning()) {
buildClientAtFirstTime(); buildClientAtFirstTime();
boolean sucess = serverCheck(); boolean sucess = serverCheck();
if (sucess) { if (sucess) {
if (rpcClientStatus.get() == RpcClientStatus.RE_CONNECTING) { if (rpcClientStatus.get() == RpcClientStatus.RE_CONNECTING) {
notifyReConnected(); notifyReConnected();
} }
System.out.println("Current Server..." + getServerListFactory().getCurrentServer()); LOGGER.info("Server check success, Current Server is {}" + getServerListFactory()
.getCurrentServer());
rpcClientStatus.compareAndSet(rpcClientStatus.get(), RpcClientStatus.RUNNING); rpcClientStatus.compareAndSet(rpcClientStatus.get(), RpcClientStatus.RUNNING);
reConnectTimesLeft.set(MAX_RECONNECT_TIMES); reConnectTimesLeft.set(MAX_RECONNECT_TIMES);
@ -332,6 +330,7 @@ public class GrpcClient extends RpcClient {
GrpcResponse response = grpcServiceStub.request(grpcrequest); GrpcResponse response = grpcServiceStub.request(grpcrequest);
String type = response.getType(); String type = response.getType();
String bodyString = response.getBody().getValue().toStringUtf8(); String bodyString = response.getBody().getValue().toStringUtf8();
// transfrom grpcResponse to response model // transfrom grpcResponse to response model
Class classByType = ResponseRegistry.getClassByType(type); Class classByType = ResponseRegistry.getClassByType(type);
if (classByType != null) { if (classByType != null) {
@ -343,7 +342,7 @@ public class GrpcClient extends RpcClient {
return (PlainBodyResponse) myresponse; return (PlainBodyResponse) myresponse;
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(System.out); LOGGER.error("grpc client request error, error message is ", e.getMessage(), e);
throw new NacosException(NacosException.SERVER_ERROR, e); throw new NacosException(NacosException.SERVER_ERROR, e);
} }
} }

View File

@ -38,10 +38,11 @@ public class ConfigTest {
@Before @Before
public void before() throws Exception { public void before() throws Exception {
Properties properties = new Properties(); Properties properties = new Properties();
//properties.setProperty(PropertyKeyConst.SERVER_ADDR, "127.0.0.1:28848"); properties.setProperty(PropertyKeyConst.SERVER_ADDR, "127.0.0.1:28848");
properties.setProperty(PropertyKeyConst.SERVER_ADDR, // properties.setProperty(PropertyKeyConst.SERVER_ADDR,
"11.239.114.187:8848,11.239.113.204:8848,11.239.112.161:8848"); // "11.239.114.187:8848,11.239.113.204:8848,11.239.112.161:8848");
// //"11.239.114.187:8848");
configService = NacosFactory.createConfigService(properties); configService = NacosFactory.createConfigService(properties);
} }
@ -50,7 +51,6 @@ public class ConfigTest {
configService.shutDown(); configService.shutDown();
} }
@Test @Test
public void test() throws Exception { public void test() throws Exception {
@ -58,27 +58,19 @@ public class ConfigTest {
final String group = "lessspring"; final String group = "lessspring";
final String content = "lessspring-" + System.currentTimeMillis(); final String content = "lessspring-" + System.currentTimeMillis();
boolean result = configService.publishConfig(dataId, group, content); boolean result = configService.publishConfig(dataId, group, content);
// Assert.assertTrue(result); Assert.assertTrue(result);
ThreadUtils.sleep(200L); ThreadUtils.sleep(200L);
ConfigListener1 listener1 = new ConfigListener1(); configService.getConfigAndSignListener(dataId, group, 5000, new AbstractListener() {
ConfigListener2 listener2 = new ConfigListener2(); @Override
public void receiveConfigInfo(String configInfo) {
configService.getConfigAndSignListener(dataId, group, 5000, listener1); System.out.println("receiveConfigInfo :" + configInfo);
}
boolean testchange = configService.publishConfig(dataId, group, "testchange" + System.currentTimeMillis()); });
System.out.println("发布配置testchange");
String config = configService.getConfig(dataId, group, 3000L);
System.out.println("查询配置content=" + config);
configService.removeConfig(dataId, group); configService.removeConfig(dataId, group);
String config2 = configService.getConfig(dataId, group, 3000L);
System.out.println("移除后查询配置content=" + config2);
configService.getConfigAndSignListener("lessspring2", group, 5000, listener1);
configService.publishConfig("lessspring2", group, "lessspring2value"); configService.publishConfig("lessspring2", group, "lessspring2value");
Scanner scanner = new Scanner(System.in); Scanner scanner = new Scanner(System.in);
@ -93,21 +85,4 @@ public class ConfigTest {
} }
} }
}
class ConfigListener1 extends AbstractListener {
@Override
public void receiveConfigInfo(String configInfo) {
System.err.println("Listener1 invoked." + configInfo);
}
}
class ConfigListener2 extends AbstractListener {
@Override
public void receiveConfigInfo(String configInfo) {
System.err.println("Listener2 invoked." + configInfo);
}
} }

View File

@ -31,6 +31,7 @@ import com.alibaba.nacos.config.server.service.trace.ConfigTraceService;
import com.alibaba.nacos.config.server.utils.ParamUtils; import com.alibaba.nacos.config.server.utils.ParamUtils;
import com.alibaba.nacos.config.server.utils.TimeUtils; import com.alibaba.nacos.config.server.utils.TimeUtils;
import com.alibaba.nacos.core.remote.RequestHandler; import com.alibaba.nacos.core.remote.RequestHandler;
import com.alibaba.nacos.core.utils.Loggers;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -84,7 +85,7 @@ public class ConfiRemoveRequestHandler extends RequestHandler {
return ConfigRemoveResponse.buildSuccessResponse(); return ConfigRemoveResponse.buildSuccessResponse();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); Loggers.GRPC_DIGEST.error("remove config error,error msg is {}", e.getMessage(), e);
return ConfigRemoveResponse.buildFailResponse(e.getMessage()); return ConfigRemoveResponse.buildFailResponse(e.getMessage());
} }
} }

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.config.server.remote;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/**
* config change listen context.
*
* @author liuzunfei
* @version $Id: ConfigChangeListenContext.java, v 0.1 2020年07月20日 1:37 PM liuzunfei Exp $
*/
@Component
public class ConfigChangeListenContext {
/**
* groupKey-> connnection set.
*/
private Map<String, Set<String>> groupKeyContext = new HashMap<String, Set<String>>();
/**
* connectionId-> groupkey set.
*/
private Map<String, Set<String>> connectionIdContext = new HashMap<String, Set<String>>();
/**
* add listen .
*
* @param listenKey listenKey.
* @param connectionId connectionId.
*/
public void addListen(String listenKey, String connectionId) {
// 1.add groupKeyContext
Set<String> listenClients = groupKeyContext.get(listenKey);
if (listenClients == null) {
groupKeyContext.putIfAbsent(listenKey, new HashSet<String>());
listenClients = groupKeyContext.get(listenKey);
}
listenClients.add(connectionId);
// 2.add connectionIdContext
Set<String> groupKeys = connectionIdContext.get(connectionId);
if (groupKeys == null) {
connectionIdContext.putIfAbsent(connectionId, new HashSet<>());
groupKeys = connectionIdContext.get(connectionId);
}
groupKeys.add(listenKey);
}
/**
* remove listen context for connectionId ..
*
* @param lisnteKey lisnteKey
* @param connectionId connectionId
*/
public void removeListen(String lisnteKey, String connectionId) {
//1. remove groupKeyContext
Set<String> connectionIds = groupKeyContext.get(lisnteKey);
if (connectionIds != null) {
connectionIds.remove(connectionId);
}
//2.remove connectionIdContext
Set<String> groupKeys = connectionIdContext.get(connectionId);
if (groupKeys != null) {
groupKeys.remove(lisnteKey);
}
}
public Set<String> getListeners(String listenKey) {
if (groupKeyContext.containsKey(listenKey)) {
return groupKeyContext.get(listenKey);
}
return null;
}
/**
* remove the context related to the connectionid.
*
* @param connectionId connectionId.
*/
public void removeConnectionId(final String connectionId) {
Set<String> groupKeysinner = connectionIdContext.get(connectionId);
if (groupKeysinner != null) {
Set<String> groupKeys = new HashSet<String>(groupKeysinner);
for (String groupKey : groupKeys) {
removeListen(groupKey, connectionId);
}
}
connectionIdContext.remove(connectionId);
}
}

View File

@ -16,8 +16,6 @@
package com.alibaba.nacos.config.server.remote; package com.alibaba.nacos.config.server.remote;
import java.util.List;
import com.alibaba.nacos.api.config.remote.request.ConfigChangeListenRequest; import com.alibaba.nacos.api.config.remote.request.ConfigChangeListenRequest;
import com.alibaba.nacos.api.config.remote.request.ConfigRequestTypeConstants; import com.alibaba.nacos.api.config.remote.request.ConfigRequestTypeConstants;
import com.alibaba.nacos.api.config.remote.response.ConfigChangeListenResponse; import com.alibaba.nacos.api.config.remote.response.ConfigChangeListenResponse;
@ -27,16 +25,16 @@ import com.alibaba.nacos.api.remote.request.RequestMeta;
import com.alibaba.nacos.api.remote.response.Response; import com.alibaba.nacos.api.remote.response.Response;
import com.alibaba.nacos.common.utils.JacksonUtils; import com.alibaba.nacos.common.utils.JacksonUtils;
import com.alibaba.nacos.config.server.utils.GroupKey2; import com.alibaba.nacos.config.server.utils.GroupKey2;
import com.alibaba.nacos.core.remote.AsyncListenContext;
import com.alibaba.nacos.core.remote.NacosRemoteConstants;
import com.alibaba.nacos.core.remote.RequestHandler; import com.alibaba.nacos.core.remote.RequestHandler;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.List;
/** /**
* config change listen request handler. * config change listen request handler.
*
* @author liuzunfei * @author liuzunfei
* @version $Id: ConfigChangeListenRequestHandler.java, v 0.1 2020年07月14日 10:11 AM liuzunfei Exp $ * @version $Id: ConfigChangeListenRequestHandler.java, v 0.1 2020年07月14日 10:11 AM liuzunfei Exp $
*/ */
@ -44,13 +42,13 @@ import org.springframework.stereotype.Component;
public class ConfigChangeListenRequestHandler extends RequestHandler { public class ConfigChangeListenRequestHandler extends RequestHandler {
@Autowired @Autowired
AsyncListenContext asyncListenContext; ConfigChangeListenContext configChangeListenContext;
@Override @Override
public Request parseBodyString(String bodyString) { public Request parseBodyString(String bodyString) {
return JacksonUtils.toObj(bodyString, ConfigChangeListenRequest.class); return JacksonUtils.toObj(bodyString, ConfigChangeListenRequest.class);
} }
@Override @Override
public Response handle(Request request, RequestMeta requestMeta) throws NacosException { public Response handle(Request request, RequestMeta requestMeta) throws NacosException {
ConfigChangeListenRequest configChangeListenRequest = (ConfigChangeListenRequest) request; ConfigChangeListenRequest configChangeListenRequest = (ConfigChangeListenRequest) request;
@ -60,15 +58,16 @@ public class ConfigChangeListenRequestHandler extends RequestHandler {
String configKey = GroupKey2.getKey(dataId, group, tenant); String configKey = GroupKey2.getKey(dataId, group, tenant);
String connectionId = requestMeta.getConnectionId(); String connectionId = requestMeta.getConnectionId();
if (configChangeListenRequest.isCancelListen()) { if (configChangeListenRequest.isCancelListen()) {
asyncListenContext.removeListen(NacosRemoteConstants.LISTEN_CONTEXT_CONFIG, configKey, connectionId); configChangeListenContext.removeListen(configKey, connectionId);
} else { } else {
asyncListenContext.addListen(NacosRemoteConstants.LISTEN_CONTEXT_CONFIG, configKey, connectionId); configChangeListenContext.addListen(configKey, connectionId);
} }
return ConfigChangeListenResponse.buildSucessResponse(); return ConfigChangeListenResponse.buildSucessResponse();
} }
@Override @Override
public List<String> getRequestTypes() { public List<String> getRequestTypes() {
return Lists.newArrayList(ConfigRequestTypeConstants.CHANGE_LISTEN_CONFIG_OPERATION); return Lists.newArrayList(ConfigRequestTypeConstants.CHANGE_LISTEN_CONFIG_OPERATION);
} }
} }

View File

@ -0,0 +1,57 @@
/*
* 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.config.server.remote;
import com.alibaba.nacos.api.remote.response.ServerPushResponse;
import com.alibaba.nacos.common.utils.CollectionUtils;
import com.alibaba.nacos.core.remote.RpcPushService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Set;
/**
* ConfigChangeNotifier.
*
* @author liuzunfei
* @version $Id: ConfigChangeNotifier.java, v 0.1 2020年07月20日 3:00 PM liuzunfei Exp $
*/
@Component
public class ConfigChangeNotifier {
@Autowired
ConfigChangeListenContext configChangeListenContext;
@Autowired
private RpcPushService rpcPushService;
/**
* adaptor to config module ,when server side congif change ,invoke this method.
*
* @param groupKey groupKey
* @param notifyResponse notifyResponse
*/
public void configDataChanged(String groupKey, ServerPushResponse notifyResponse) {
Set<String> listeners = configChangeListenContext.getListeners(groupKey);
if (!CollectionUtils.isEmpty(listeners)) {
for (String connectionId : listeners) {
rpcPushService.push(connectionId, notifyResponse);
}
}
}
}

View File

@ -0,0 +1,49 @@
/*
* 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.config.server.remote;
import com.alibaba.nacos.api.remote.connection.Connection;
import com.alibaba.nacos.core.remote.ClientConnectionEventListener;
import com.alibaba.nacos.core.utils.Loggers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* ConfigConnectionEventListener.
*
* @author liuzunfei
* @version $Id: ConfigConnectionEventListener.java, v 0.1 2020年07月20日 2:27 PM liuzunfei Exp $
*/
@Component
public class ConfigConnectionEventListener extends ClientConnectionEventListener {
@Autowired
ConfigChangeListenContext configChangeListenContext;
@Override
public void clientConnected(Connection connect) {
//Do nothing.
}
@Override
public void clientDisConnected(Connection connect) {
Loggers.GRPC
.info("client disconnected,clear config listen context, connetionId is {}", connect.getConnectionId());
configChangeListenContext.removeConnectionId(connect.getConnectionId());
}
}

View File

@ -121,7 +121,7 @@ public class ConfigQueryRequestHandler extends RequestHandler {
} }
} }
String configType = cacheItem.getType(); String configType = cacheItem.getType();
response.setContentType(configType); response.setContentType((null != configType) ? configType : "text");
} }
File file = null; File file = null;
ConfigInfoBase configInfoBase = null; ConfigInfoBase configInfoBase = null;
@ -134,7 +134,7 @@ public class ConfigQueryRequestHandler extends RequestHandler {
} else { } else {
file = DiskUtil.targetBetaFile(dataId, group, tenant); file = DiskUtil.targetBetaFile(dataId, group, tenant);
} }
response.addLabel("beta", "Y"); response.addLabel("isBeta", "Y");
} else { } else {
if (StringUtils.isBlank(tag)) { if (StringUtils.isBlank(tag)) {
if (isUseTag(cacheItem, autoTag)) { if (isUseTag(cacheItem, autoTag)) {

View File

@ -25,13 +25,12 @@ import com.alibaba.nacos.common.utils.ExceptionUtil;
import com.alibaba.nacos.config.server.model.SampleResult; import com.alibaba.nacos.config.server.model.SampleResult;
import com.alibaba.nacos.config.server.model.event.LocalDataChangeEvent; import com.alibaba.nacos.config.server.model.event.LocalDataChangeEvent;
import com.alibaba.nacos.config.server.monitor.MetricsMonitor; import com.alibaba.nacos.config.server.monitor.MetricsMonitor;
import com.alibaba.nacos.config.server.remote.ConfigChangeNotifier;
import com.alibaba.nacos.config.server.utils.ConfigExecutor; import com.alibaba.nacos.config.server.utils.ConfigExecutor;
import com.alibaba.nacos.config.server.utils.GroupKey; import com.alibaba.nacos.config.server.utils.GroupKey;
import com.alibaba.nacos.config.server.utils.LogUtil; import com.alibaba.nacos.config.server.utils.LogUtil;
import com.alibaba.nacos.config.server.utils.MD5Util; import com.alibaba.nacos.config.server.utils.MD5Util;
import com.alibaba.nacos.config.server.utils.RequestUtil; import com.alibaba.nacos.config.server.utils.RequestUtil;
import com.alibaba.nacos.core.remote.DataChangeListenerNotifier;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -74,7 +73,7 @@ public class LongPollingService {
private static final String TRUE_STR = "true"; private static final String TRUE_STR = "true";
@Autowired @Autowired
private DataChangeListenerNotifier dataChangeListenerNotifier; private ConfigChangeNotifier configChangeNotifier;
private Map<String, Long> retainIps = new ConcurrentHashMap<String, Long>(); private Map<String, Long> retainIps = new ConcurrentHashMap<String, Long>();
@ -366,7 +365,7 @@ public class LongPollingService {
String tenant = strings.length > 2 ? strings[2] : ""; String tenant = strings.length > 2 ? strings[2] : "";
ConfigChangeNotifyResponse notifyResponse = ConfigChangeNotifyResponse ConfigChangeNotifyResponse notifyResponse = ConfigChangeNotifyResponse
.buildSuccessResponse(dataid, group, tenant); .buildSuccessResponse(dataid, group, tenant);
dataChangeListenerNotifier.configDataChanged(groupKey, notifyResponse); configChangeNotifier.configDataChanged(groupKey, notifyResponse);
} catch (Throwable t) { } catch (Throwable t) {
LogUtil.DEFAULT_LOG.error("data change error: {}", ExceptionUtil.getStackTrace(t)); LogUtil.DEFAULT_LOG.error("data change error: {}", ExceptionUtil.getStackTrace(t));

View File

@ -155,5 +155,4 @@ public class ParamUtils {
} }
} }
} }

View File

@ -17,6 +17,9 @@
package com.alibaba.nacos.core.remote; package com.alibaba.nacos.core.remote;
import com.alibaba.nacos.api.remote.connection.Connection; import com.alibaba.nacos.api.remote.connection.Connection;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.PostConstruct;
/** /**
* ClientConnectionEventListener. * ClientConnectionEventListener.
@ -24,20 +27,51 @@ import com.alibaba.nacos.api.remote.connection.Connection;
* @author liuzunfei * @author liuzunfei
* @version $Id: ClientConnectionEventListener.java, v 0.1 2020年07月16日 3:06 PM liuzunfei Exp $ * @version $Id: ClientConnectionEventListener.java, v 0.1 2020年07月16日 3:06 PM liuzunfei Exp $
*/ */
public interface ClientConnectionEventListener { public abstract class ClientConnectionEventListener {
/**
* lisnter name.
*/
private String name;
@Autowired
protected ClientConnectionEventListenerRegistry clientConnectionEventListenerRegistry;
@PostConstruct
public void init() {
clientConnectionEventListenerRegistry.registerClientConnectionEventListener(this);
}
/**
* Getter method for property <tt>name</tt>.
*
* @return property value of name
*/
public String getName() {
return name;
}
/**
* Setter method for property <tt>name</tt>.
*
* @param name value to be assigned to property name
*/
public void setName(String name) {
this.name = name;
}
/** /**
* notified when a client connected. * notified when a client connected.
* *
* @param connect connect. * @param connect connect.
*/ */
public void clientConnected(Connection connect); public abstract void clientConnected(Connection connect);
/** /**
* notified when a client disconnected. * notified when a client disconnected.
* *
* @param connect connect. * @param connect connect.
*/ */
public void clientDisConnected(Connection connect); public abstract void clientDisConnected(Connection connect);
} }

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.core.remote;
import com.alibaba.nacos.core.utils.Loggers;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* regitry for client connection event listeners.
*
* @author liuzunfei
* @version $Id: ClientConnectionEventListenerRegistry.java, v 0.1 2020年07月20日 1:47 PM liuzunfei Exp $
*/
@Service
public class ClientConnectionEventListenerRegistry {
final List<ClientConnectionEventListener> clientConnectionEventListeners = new ArrayList<ClientConnectionEventListener>();
/**
* register ClientConnectionEventListener.
*
* @param listener listener.
*/
public void registerClientConnectionEventListener(ClientConnectionEventListener listener) {
Loggers.GRPC.info("[ClientConnectionEventListenerRegistry] registry listener - " + listener.getClass().getSimpleName());
this.clientConnectionEventListeners.add(listener);
}
}

View File

@ -22,9 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -39,14 +37,15 @@ import java.util.concurrent.TimeUnit;
@Service @Service
public class ConnectCoordinator implements ConnectionHeathyChecker { public class ConnectCoordinator implements ConnectionHeathyChecker {
final List<ClientConnectionEventListener> clientConnectionEventListeners = new ArrayList<ClientConnectionEventListener>(); @Autowired
private ClientConnectionEventListenerRegistry clientConnectionEventListenerRegistry;
@Autowired @Autowired
ConnectionManager connectionManager; ConnectionManager connectionManager;
private ScheduledExecutorService executors = Executors.newScheduledThreadPool(1); private ScheduledExecutorService executors = Executors.newScheduledThreadPool(1);
private static final long EXPIRE_MILLSECOND = 15000L; private static final long EXPIRE_MILLSECOND = 10000L;
/** /**
* Start TaskExpel the connection which active Time expire. * Start TaskExpel the connection which active Time expire.
@ -69,7 +68,7 @@ public class ConnectCoordinator implements ConnectionHeathyChecker {
connectionManager.unregister(conn.getConnectionId()); connectionManager.unregister(conn.getConnectionId());
Loggers.GRPC.info("expire connection found success expel connectionid = {} ", Loggers.GRPC.info("expire connection found success expel connectionid = {} ",
conn.getConnectionId()); conn.getConnectionId());
for (ClientConnectionEventListener listener : clientConnectionEventListeners) { for (ClientConnectionEventListener listener : clientConnectionEventListenerRegistry.clientConnectionEventListeners) {
listener.clientDisConnected(conn); listener.clientDisConnected(conn);
} }
@ -83,8 +82,4 @@ public class ConnectCoordinator implements ConnectionHeathyChecker {
}, 500L, 5000L, TimeUnit.MILLISECONDS); }, 500L, 5000L, TimeUnit.MILLISECONDS);
} }
public void registerClientConnectionEventListener(ClientConnectionEventListener listener) {
this.clientConnectionEventListeners.add(listener);
}
} }

View File

@ -13,9 +13,11 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.alibaba.nacos.core.remote; package com.alibaba.nacos.core.remote;
/** /**
* ConnectionHeathyChecker.
* @author liuzunfei * @author liuzunfei
* @version $Id: ConnectionHeathyChecker.java, v 0.1 2020年07月14日 12:01 AM liuzunfei Exp $ * @version $Id: ConnectionHeathyChecker.java, v 0.1 2020年07月14日 12:01 AM liuzunfei Exp $
*/ */

View File

@ -20,9 +20,7 @@ import com.alibaba.nacos.api.remote.connection.Connection;
import com.alibaba.nacos.core.utils.Loggers; import com.alibaba.nacos.core.utils.Loggers;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -36,7 +34,6 @@ public class ConnectionManager {
Map<String, Connection> connetions = new HashMap<String, Connection>(); Map<String, Connection> connetions = new HashMap<String, Connection>();
/** /**
* register a new connect. * register a new connect.
* *

View File

@ -28,5 +28,4 @@ public class NacosRemoteConstants {
public static final String LISTEN_CONTEXT_NAMING = "NAMING"; public static final String LISTEN_CONTEXT_NAMING = "NAMING";
} }

View File

@ -0,0 +1,31 @@
/*
* 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.core.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 {
public void onSuccess();
public void onException();
}

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.core.remote;
import com.alibaba.nacos.api.remote.connection.Connection;
import com.alibaba.nacos.api.remote.response.ServerPushResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* push response to clients.
*
* @author liuzunfei
* @version $Id: PushService.java, v 0.1 2020年07月20日 1:12 PM liuzunfei Exp $
*/
@Service
public class RpcPushService {
@Autowired
private ConnectionManager connectionManager;
/**
* push response without callback.
*
* @param connectionId connectionId.
* @param response response.
*/
public void push(String connectionId, ServerPushResponse response) {
Connection connection = connectionManager.getConnection(connectionId);
if (connection != null) {
connection.sendResponse(response);
}
}
/**
* push response with callback. [not support yet]
*
* @param connectionId connectionId.
* @param response response.
* @param pushCallBack pushCallBack.
*/
public void push(String connectionId, ServerPushResponse response, PushCallBack pushCallBack) {
push(connectionId, response);
}
}

View File

@ -23,13 +23,6 @@ package com.alibaba.nacos.core.remote;
*/ */
public abstract class RpcServer { public abstract class RpcServer {
/**
* register a ClientConnectionEventListener.
*
* @param eventListener eventListener.
*/
public abstract void registerClientConnectionEventListener(ClientConnectionEventListener eventListener);
/** /**
* Start sever. * Start sever.
*/ */

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.alibaba.nacos.core.remote.grpc; package com.alibaba.nacos.core.remote.grpc;
import com.alibaba.nacos.api.remote.connection.Connection; import com.alibaba.nacos.api.remote.connection.Connection;
@ -22,25 +23,24 @@ import com.alibaba.nacos.api.remote.response.Response;
import io.grpc.stub.StreamObserver; import io.grpc.stub.StreamObserver;
/** /**
* grpc connection.
* @author liuzunfei * @author liuzunfei
* @version $Id: GrpcConnection.java, v 0.1 2020年07月13日 7:26 PM liuzunfei Exp $ * @version $Id: GrpcConnection.java, v 0.1 2020年07月13日 7:26 PM liuzunfei Exp $
*/ */
public class GrpcConnection extends Connection { public class GrpcConnection extends Connection {
private StreamObserver streamObserver; private StreamObserver streamObserver;
public GrpcConnection(ConnectionMetaInfo metaInfo,StreamObserver streamObserver) { public GrpcConnection(ConnectionMetaInfo metaInfo, StreamObserver streamObserver) {
super(metaInfo); super(metaInfo);
this.streamObserver=streamObserver; this.streamObserver = streamObserver;
} }
@Override @Override
public void sendResponse(Response reponse) { public void sendResponse(Response reponse) {
streamObserver.onNext(GrpcUtils.convert(reponse)); streamObserver.onNext(GrpcUtils.convert(reponse));
} }
@Override @Override
public void closeGrapcefully() { public void closeGrapcefully() {
//Empty implements //Empty implements

View File

@ -16,7 +16,7 @@
package com.alibaba.nacos.core.remote.grpc; package com.alibaba.nacos.core.remote.grpc;
import com.alibaba.nacos.core.remote.ClientConnectionEventListener; import com.alibaba.nacos.core.remote.ClientConnectionEventListenerRegistry;
import com.alibaba.nacos.core.remote.ConnectCoordinator; import com.alibaba.nacos.core.remote.ConnectCoordinator;
import com.alibaba.nacos.core.remote.ConnectionManager; import com.alibaba.nacos.core.remote.ConnectionManager;
import com.alibaba.nacos.core.remote.RequestHandlerRegistry; import com.alibaba.nacos.core.remote.RequestHandlerRegistry;
@ -41,6 +41,8 @@ public class GrpcServer extends RpcServer {
private Server server; private Server server;
@Autowired
private ClientConnectionEventListenerRegistry clientConnectionEventListenerRegistry;
@Autowired @Autowired
private ConnectCoordinator connectCoordinator; private ConnectCoordinator connectCoordinator;
@ -68,11 +70,6 @@ public class GrpcServer extends RpcServer {
Loggers.GRPC.info("Request handler Registry inited :" + requestHandlerRegistry); Loggers.GRPC.info("Request handler Registry inited :" + requestHandlerRegistry);
} }
@Override
public void registerClientConnectionEventListener(ClientConnectionEventListener eventListener) {
connectCoordinator.registerClientConnectionEventListener(eventListener);
}
@PostConstruct @PostConstruct
@Override @Override
public void start() throws Exception { public void start() throws Exception {

73
pom.xml
View File

@ -1016,17 +1016,72 @@
</dependency> </dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
<distributionManagement> <!--<distributionManagement>-->
<snapshotRepository> <!--<snapshotRepository>-->
<!-- 这里的ID一定要在maven setting文件中存在于server下的ID --> <!--&lt;!&ndash; 这里的ID一定要在maven setting文件中存在于server下的ID &ndash;&gt;-->
<id>sona</id> <!--<id>sona</id>-->
<url>https://oss.sonatype.org/content/repositories/snapshots/</url> <!--<url>https://oss.sonatype.org/content/repositories/snapshots/</url>-->
</snapshotRepository> <!--</snapshotRepository>-->
<!--<repository>-->
<!--<id>sona</id>-->
<!--<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>-->
<!--</repository>-->
<!--</distributionManagement>-->
<repositories>
<repository> <repository>
<id>sona</id> <id>central</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url> <url>http://mvnrepo.alibaba-inc.com/mvn/repository</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository> </repository>
<repository>
<id>snapshots</id>
<url>http://mvnrepo.alibaba-inc.com/mvn/repository</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://mvnrepo.alibaba-inc.com/mvn/repository</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>snapshots</id>
<url>http://mvnrepo.alibaba-inc.com/mvn/repository</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<distributionManagement>
<repository>
<id>releases</id>
<url>http://mvnrepo.alibaba-inc.com/mvn/releases</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://mvnrepo.alibaba-inc.com/mvn/snapshots</url>
</snapshotRepository>
</distributionManagement> </distributionManagement>
</project> </project>