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_ = "";
- /**
- * string type = 2;
- */
- 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;
- }
- }
- /**
- * string type = 2;
- */
- 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;
- }
- }
- /**
- * string type = 2;
- */
- public Builder setType(
- String value) {
- if (value == null) {
- throw new NullPointerException();
- }
-
- type_ = value;
- onChanged();
- return this;
- }
- /**
- * string type = 2;
- */
- public Builder clearType() {
-
- type_ = getDefaultInstance().getType();
- onChanged();
- return this;
- }
- /**
- * string type = 2;
- */
- 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_;
- /**
- *
- * Common metadata describing the resource.
- *
- *
- * .GrpcMetadata metadata = 1;
- */
- public boolean hasMetadata() {
- return metadataBuilder_ != null || metadata_ != null;
- }
- /**
- *
- * Common metadata describing the resource.
- *
- *
- * .GrpcMetadata metadata = 1;
- */
- public GrpcMetadata getMetadata() {
- if (metadataBuilder_ == null) {
- return metadata_ == null ? GrpcMetadata.getDefaultInstance() : metadata_;
- } else {
- return metadataBuilder_.getMessage();
- }
- }
- /**
- *
- * Common metadata describing the resource.
- *
- *
- * .GrpcMetadata metadata = 1;
- */
- public Builder setMetadata(GrpcMetadata value) {
- if (metadataBuilder_ == null) {
- if (value == null) {
- throw new NullPointerException();
- }
- metadata_ = value;
- onChanged();
- } else {
- metadataBuilder_.setMessage(value);
- }
-
- return this;
- }
- /**
- *
- * Common metadata describing the resource.
- *
- *
- * .GrpcMetadata metadata = 1;
- */
- public Builder setMetadata(
- GrpcMetadata.Builder builderForValue) {
- if (metadataBuilder_ == null) {
- metadata_ = builderForValue.build();
- onChanged();
- } else {
- metadataBuilder_.setMessage(builderForValue.build());
- }
-
- return this;
- }
- /**
- *
- * Common metadata describing the resource.
- *
- *
- * .GrpcMetadata metadata = 1;
- */
- 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;
- }
- /**
- *
- * Common metadata describing the resource.
- *
- *
- * .GrpcMetadata metadata = 1;
- */
- public Builder clearMetadata() {
- if (metadataBuilder_ == null) {
- metadata_ = null;
- onChanged();
- } else {
- metadata_ = null;
- metadataBuilder_ = null;
- }
-
- return this;
- }
- /**
- *
- * Common metadata describing the resource.
- *
- *
- * .GrpcMetadata metadata = 1;
- */
- public GrpcMetadata.Builder getMetadataBuilder() {
-
- onChanged();
- return getMetadataFieldBuilder().getBuilder();
- }
- /**
- *
- * Common metadata describing the resource.
- *
- *
- * .GrpcMetadata metadata = 1;
- */
- public GrpcMetadataOrBuilder getMetadataOrBuilder() {
- if (metadataBuilder_ != null) {
- return metadataBuilder_.getMessageOrBuilder();
- } else {
- return metadata_ == null ?
- GrpcMetadata.getDefaultInstance() : metadata_;
- }
- }
- /**
- *
- * Common metadata describing the resource.
- *
- *
- * .GrpcMetadata metadata = 1;
- */
- 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_;
- /**
- *
- * The primary payload for the resource.
- *
- *
- * .google.protobuf.Any body = 3;
- */
- public boolean hasBody() {
- return bodyBuilder_ != null || body_ != null;
- }
- /**
- *
- * The primary payload for the resource.
- *
- *
- * .google.protobuf.Any body = 3;
- */
- public com.google.protobuf.Any getBody() {
- if (bodyBuilder_ == null) {
- return body_ == null ? com.google.protobuf.Any.getDefaultInstance() : body_;
- } else {
- return bodyBuilder_.getMessage();
- }
- }
- /**
- *
- * The primary payload for the resource.
- *
- *
- * .google.protobuf.Any body = 3;
- */
- 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;
- }
- /**
- *
- * The primary payload for the resource.
- *
- *
- * .google.protobuf.Any body = 3;
- */
- public Builder setBody(
- com.google.protobuf.Any.Builder builderForValue) {
- if (bodyBuilder_ == null) {
- body_ = builderForValue.build();
- onChanged();
- } else {
- bodyBuilder_.setMessage(builderForValue.build());
- }
-
- return this;
- }
- /**
- *
- * The primary payload for the resource.
- *
- *
- * .google.protobuf.Any body = 3;
- */
- 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;
- }
- /**
- *
- * The primary payload for the resource.
- *
- *
- * .google.protobuf.Any body = 3;
- */
- public Builder clearBody() {
- if (bodyBuilder_ == null) {
- body_ = null;
- onChanged();
- } else {
- body_ = null;
- bodyBuilder_ = null;
- }
-
- return this;
- }
- /**
- *
- * The primary payload for the resource.
- *
- *
- * .google.protobuf.Any body = 3;
- */
- public com.google.protobuf.Any.Builder getBodyBuilder() {
-
- onChanged();
- return getBodyFieldBuilder().getBuilder();
- }
- /**
- *
- * The primary payload for the resource.
- *
- *
- * .google.protobuf.Any body = 3;
- */
- public com.google.protobuf.AnyOrBuilder getBodyOrBuilder() {
- if (bodyBuilder_ != null) {
- return bodyBuilder_.getMessageOrBuilder();
- } else {
- return body_ == null ?
- com.google.protobuf.Any.getDefaultInstance() : body_;
- }
- }
- /**
- *
- * The primary payload for the resource.
- *
- *
- * .google.protobuf.Any body = 3;
- */
- 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
- PARSER = new com.google.protobuf.AbstractParser() {
- 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 parser() {
- return PARSER;
- }
-
- @Override
- public com.google.protobuf.Parser getParserForType() {
- return PARSER;
- }
-
- public GrpcRequest getDefaultInstanceForType() {
- return DEFAULT_INSTANCE;
- }
-
-}
-
diff --git a/api/src/main/java/com/alibaba/nacos/api/grpc/GrpcRequestOrBuilder.java b/api/src/main/java/com/alibaba/nacos/api/grpc/GrpcRequestOrBuilder.java
deleted file mode 100644
index f1bc88615..000000000
--- a/api/src/main/java/com/alibaba/nacos/api/grpc/GrpcRequestOrBuilder.java
+++ /dev/null
@@ -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 {
-
- /**
- * string type = 2;
- */
- String getType();
- /**
- * string type = 2;
- */
- com.google.protobuf.ByteString
- getTypeBytes();
-
- /**
- *
- * Common metadata describing the resource.
- *
- *
- * .GrpcMetadata metadata = 1;
- */
- boolean hasMetadata();
- /**
- *
- * Common metadata describing the resource.
- *
- *
- * .GrpcMetadata metadata = 1;
- */
- GrpcMetadata getMetadata();
- /**
- *
- * Common metadata describing the resource.
- *
- *
- * .GrpcMetadata metadata = 1;
- */
- GrpcMetadataOrBuilder getMetadataOrBuilder();
-
- /**
- *
- * The primary payload for the resource.
- *
- *
- * .google.protobuf.Any body = 3;
- */
- boolean hasBody();
- /**
- *
- * The primary payload for the resource.
- *
- *
- * .google.protobuf.Any body = 3;
- */
- com.google.protobuf.Any getBody();
- /**
- *
- * The primary payload for the resource.
- *
- *
- * .google.protobuf.Any body = 3;
- */
- com.google.protobuf.AnyOrBuilder getBodyOrBuilder();
-}
diff --git a/api/src/main/java/com/alibaba/nacos/api/grpc/GrpcResponse.java b/api/src/main/java/com/alibaba/nacos/api/grpc/GrpcResponse.java
deleted file mode 100644
index d15081730..000000000
--- a/api/src/main/java/com/alibaba/nacos/api/grpc/GrpcResponse.java
+++ /dev/null
@@ -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_;
-
- /**
- * int32 code = 1;
- */
- public int getCode() {
- return code_;
- }
-
- public static final int BODY_FIELD_NUMBER = 2;
-
- private com.google.protobuf.Any body_;
-
- /**
- *
- * reponse body
- *
- *
- * .google.protobuf.Any body = 2;
- */
- public boolean hasBody() {
- return body_ != null;
- }
-
- /**
- *
- * reponse body
- *
- *
- * .google.protobuf.Any body = 2;
- */
- public com.google.protobuf.Any getBody() {
- return body_ == null ? com.google.protobuf.Any.getDefaultInstance() : body_;
- }
-
- /**
- *
- * reponse body
- *
- *
- * .google.protobuf.Any body = 2;
- */
- public com.google.protobuf.AnyOrBuilder getBodyOrBuilder() {
- return getBody();
- }
-
- public static final int TYPE_FIELD_NUMBER = 3;
-
- private volatile Object type_;
-
- /**
- * string type = 3;
- */
- 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;
- }
- }
-
- /**
- * string type = 3;
- */
- 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 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_;
-
- /**
- * int32 code = 1;
- */
- public int getCode() {
- return code_;
- }
-
- /**
- * int32 code = 1;
- */
- public Builder setCode(int value) {
-
- code_ = value;
- onChanged();
- return this;
- }
-
- /**
- * int32 code = 1;
- */
- public Builder clearCode() {
-
- code_ = 0;
- onChanged();
- return this;
- }
-
- private com.google.protobuf.Any body_ = null;
-
- private com.google.protobuf.SingleFieldBuilderV3 bodyBuilder_;
-
- /**
- *
- * reponse body
- *
- *
- * .google.protobuf.Any body = 2;
- */
- public boolean hasBody() {
- return bodyBuilder_ != null || body_ != null;
- }
-
- /**
- *
- * reponse body
- *
- *
- * .google.protobuf.Any body = 2;
- */
- public com.google.protobuf.Any getBody() {
- if (bodyBuilder_ == null) {
- return body_ == null ? com.google.protobuf.Any.getDefaultInstance() : body_;
- } else {
- return bodyBuilder_.getMessage();
- }
- }
-
- /**
- *
- * reponse body
- *
- *
- * .google.protobuf.Any body = 2;
- */
- 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;
- }
-
- /**
- *
- * reponse body
- *
- *
- * .google.protobuf.Any body = 2;
- */
- public Builder setBody(com.google.protobuf.Any.Builder builderForValue) {
- if (bodyBuilder_ == null) {
- body_ = builderForValue.build();
- onChanged();
- } else {
- bodyBuilder_.setMessage(builderForValue.build());
- }
-
- return this;
- }
-
- /**
- *
- * reponse body
- *
- *
- * .google.protobuf.Any body = 2;
- */
- 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;
- }
-
- /**
- *
- * reponse body
- *
- *
- * .google.protobuf.Any body = 2;
- */
- public Builder clearBody() {
- if (bodyBuilder_ == null) {
- body_ = null;
- onChanged();
- } else {
- body_ = null;
- bodyBuilder_ = null;
- }
-
- return this;
- }
-
- /**
- *
- * reponse body
- *
- *
- * .google.protobuf.Any body = 2;
- */
- public com.google.protobuf.Any.Builder getBodyBuilder() {
-
- onChanged();
- return getBodyFieldBuilder().getBuilder();
- }
-
- /**
- *
- * reponse body
- *
- *
- * .google.protobuf.Any body = 2;
- */
- public com.google.protobuf.AnyOrBuilder getBodyOrBuilder() {
- if (bodyBuilder_ != null) {
- return bodyBuilder_.getMessageOrBuilder();
- } else {
- return body_ == null ? com.google.protobuf.Any.getDefaultInstance() : body_;
- }
- }
-
- /**
- *
- * reponse body
- *
- *
- * .google.protobuf.Any body = 2;
- */
- private com.google.protobuf.SingleFieldBuilderV3 getBodyFieldBuilder() {
- if (bodyBuilder_ == null) {
- bodyBuilder_ = new com.google.protobuf.SingleFieldBuilderV3(
- getBody(), getParentForChildren(), isClean());
- body_ = null;
- }
- return bodyBuilder_;
- }
-
- private Object type_ = "";
-
- /**
- * string type = 3;
- */
- 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;
- }
- }
-
- /**
- * string type = 3;
- */
- 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;
- }
- }
-
- /**
- * string type = 3;
- */
- public Builder setType(String value) {
- if (value == null) {
- throw new NullPointerException();
- }
-
- type_ = value;
- onChanged();
- return this;
- }
-
- /**
- * string type = 3;
- */
- public Builder clearType() {
-
- type_ = getDefaultInstance().getType();
- onChanged();
- return this;
- }
-
- /**
- * string type = 3;
- */
- 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 PARSER = new com.google.protobuf.AbstractParser() {
- 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 parser() {
- return PARSER;
- }
-
- @Override
- public com.google.protobuf.Parser getParserForType() {
- return PARSER;
- }
-
- public GrpcResponse getDefaultInstanceForType() {
- return DEFAULT_INSTANCE;
- }
-
-}
-
diff --git a/api/src/main/java/com/alibaba/nacos/api/grpc/GrpcResponseOrBuilder.java b/api/src/main/java/com/alibaba/nacos/api/grpc/GrpcResponseOrBuilder.java
deleted file mode 100644
index e5a905449..000000000
--- a/api/src/main/java/com/alibaba/nacos/api/grpc/GrpcResponseOrBuilder.java
+++ /dev/null
@@ -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 {
-
- /**
- * int32 code = 1;
- */
- int getCode();
-
- /**
- *
- * reponse body
- *
- *
- * .google.protobuf.Any body = 2;
- */
- boolean hasBody();
-
- /**
- *
- * reponse body
- *
- *
- * .google.protobuf.Any body = 2;
- */
- com.google.protobuf.Any getBody();
-
- /**
- *
- * reponse body
- *
- *
- * .google.protobuf.Any body = 2;
- */
- com.google.protobuf.AnyOrBuilder getBodyOrBuilder();
-
- /**
- * string type = 3;
- */
- String getType();
-
- /**
- * string type = 3;
- */
- com.google.protobuf.ByteString getTypeBytes();
-}
diff --git a/api/src/main/java/com/alibaba/nacos/api/grpc/NacosGrpcService.java b/api/src/main/java/com/alibaba/nacos/api/grpc/NacosGrpcService.java
deleted file mode 100644
index 6b7a58dca..000000000
--- a/api/src/main/java/com/alibaba/nacos/api/grpc/NacosGrpcService.java
+++ /dev/null
@@ -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)
-}
diff --git a/api/src/main/java/com/alibaba/nacos/api/grpc/RequestGrpc.java b/api/src/main/java/com/alibaba/nacos/api/grpc/RequestGrpc.java
deleted file mode 100644
index 69d1181b9..000000000
--- a/api/src/main/java/com/alibaba/nacos/api/grpc/RequestGrpc.java
+++ /dev/null
@@ -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 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 getRequestMethod() {
- io.grpc.MethodDescriptor getRequestMethod;
- if ((getRequestMethod = RequestGrpc.getRequestMethod) == null) {
- synchronized (RequestGrpc.class) {
- if ((getRequestMethod = RequestGrpc.getRequestMethod) == null) {
- RequestGrpc.getRequestMethod = getRequestMethod =
- io.grpc.MethodDescriptor.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 {
-
- /**
- *
- * Sends a commonRequest
- *
- */
- public void request(GrpcRequest request, io.grpc.stub.StreamObserver 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 {
- 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);
- }
-
- /**
- *
- * Sends a commonRequest
- *
- */
- public void request(GrpcRequest request, io.grpc.stub.StreamObserver responseObserver) {
- asyncUnaryCall(
- getChannel().newCall(getRequestMethod(), getCallOptions()), request, responseObserver);
- }
- }
-
- /**
- */
- public static final class RequestBlockingStub extends io.grpc.stub.AbstractStub {
- 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);
- }
-
- /**
- *
- * Sends a commonRequest
- *
- */
- public GrpcResponse request(GrpcRequest request) {
- return blockingUnaryCall(
- getChannel(), getRequestMethod(), getCallOptions(), request);
- }
- }
-
- /**
- */
- public static final class RequestFutureStub extends io.grpc.stub.AbstractStub {
- 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);
- }
-
- /**
- *
- * Sends a commonRequest
- *
- */
- public com.google.common.util.concurrent.ListenableFuture request(
- GrpcRequest request) {
- return futureUnaryCall(
- getChannel().newCall(getRequestMethod(), getCallOptions()), request);
- }
- }
-
- private static final int METHODID_REQUEST = 0;
-
- private static final class MethodHandlers implements
- io.grpc.stub.ServerCalls.UnaryMethod,
- io.grpc.stub.ServerCalls.ServerStreamingMethod,
- io.grpc.stub.ServerCalls.ClientStreamingMethod,
- io.grpc.stub.ServerCalls.BidiStreamingMethod {
- 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 responseObserver) {
- switch (methodId) {
- case METHODID_REQUEST:
- serviceImpl.request((GrpcRequest) request,
- (io.grpc.stub.StreamObserver) responseObserver);
- break;
- default:
- throw new AssertionError();
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public io.grpc.stub.StreamObserver invoke(
- io.grpc.stub.StreamObserver 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;
- }
-}
diff --git a/api/src/main/java/com/alibaba/nacos/api/grpc/RequestStreamGrpc.java b/api/src/main/java/com/alibaba/nacos/api/grpc/RequestStreamGrpc.java
deleted file mode 100644
index e8cdc310d..000000000
--- a/api/src/main/java/com/alibaba/nacos/api/grpc/RequestStreamGrpc.java
+++ /dev/null
@@ -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 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 getRequestStreamMethod() {
- io.grpc.MethodDescriptor getRequestStreamMethod;
- if ((getRequestStreamMethod = RequestStreamGrpc.getRequestStreamMethod) == null) {
- synchronized (RequestStreamGrpc.class) {
- if ((getRequestStreamMethod = RequestStreamGrpc.getRequestStreamMethod) == null) {
- RequestStreamGrpc.getRequestStreamMethod = getRequestStreamMethod =
- io.grpc.MethodDescriptor.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 {
-
- /**
- *
- * build a streamRequest
- *
- */
- public void requestStream(GrpcRequest request, io.grpc.stub.StreamObserver 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 {
- 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);
- }
-
- /**
- *
- * build a streamRequest
- *
- */
- public void requestStream(GrpcRequest request, io.grpc.stub.StreamObserver responseObserver) {
- asyncServerStreamingCall(
- getChannel().newCall(getRequestStreamMethod(), getCallOptions()), request, responseObserver);
- }
- }
-
- /**
- */
- public static final class RequestStreamBlockingStub extends io.grpc.stub.AbstractStub {
- 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);
- }
-
- /**
- *
- * build a streamRequest
- *
- */
- public java.util.Iterator requestStream(
- GrpcRequest request) {
- return blockingServerStreamingCall(
- getChannel(), getRequestStreamMethod(), getCallOptions(), request);
- }
- }
-
- /**
- */
- public static final class RequestStreamFutureStub extends io.grpc.stub.AbstractStub {
- 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 implements
- io.grpc.stub.ServerCalls.UnaryMethod,
- io.grpc.stub.ServerCalls.ServerStreamingMethod,
- io.grpc.stub.ServerCalls.ClientStreamingMethod,
- io.grpc.stub.ServerCalls.BidiStreamingMethod {
- 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 responseObserver) {
- switch (methodId) {
- case METHODID_REQUEST_STREAM:
- serviceImpl.requestStream((GrpcRequest) request,
- (io.grpc.stub.StreamObserver) responseObserver);
- break;
- default:
- throw new AssertionError();
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public io.grpc.stub.StreamObserver invoke(
- io.grpc.stub.StreamObserver 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;
- }
-}
diff --git a/api/src/main/java/com/alibaba/nacos/api/remote/connection/ConnectionType.java b/api/src/main/java/com/alibaba/nacos/api/remote/connection/ConnectionType.java
index 2a5c86996..57f689646 100644
--- a/api/src/main/java/com/alibaba/nacos/api/remote/connection/ConnectionType.java
+++ b/api/src/main/java/com/alibaba/nacos/api/remote/connection/ConnectionType.java
@@ -17,7 +17,7 @@
package com.alibaba.nacos.api.remote.connection;
/**
- * ConnectionType
+ * ConnectionType.
* @author liuzunfei
* @version $Id: ConnectionType.java, v 0.1 2020年07月13日 7:15 PM liuzunfei Exp $
*/
diff --git a/api/src/main/java/com/alibaba/nacos/api/remote/request/HeartBeatRequest.java b/api/src/main/java/com/alibaba/nacos/api/remote/request/HeartBeatRequest.java
index 0305dec33..a30d3a396 100644
--- a/api/src/main/java/com/alibaba/nacos/api/remote/request/HeartBeatRequest.java
+++ b/api/src/main/java/com/alibaba/nacos/api/remote/request/HeartBeatRequest.java
@@ -13,10 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package com.alibaba.nacos.api.remote.request;
-
/**
+ * HeartBeatRequest.
* @author liuzunfei
* @version $Id: HeartBeatRequest.java, v 0.1 2020年07月14日 11:38 AM liuzunfei Exp $
*/
diff --git a/api/src/main/java/com/alibaba/nacos/api/remote/request/RequestTypeConstants.java b/api/src/main/java/com/alibaba/nacos/api/remote/request/RequestTypeConstants.java
index 3bc62c8ef..abe3fc7bc 100644
--- a/api/src/main/java/com/alibaba/nacos/api/remote/request/RequestTypeConstants.java
+++ b/api/src/main/java/com/alibaba/nacos/api/remote/request/RequestTypeConstants.java
@@ -13,14 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package com.alibaba.nacos.api.remote.request;
/**
+ * RequestTypeConstants.
+ *
* @author liuzunfei
* @version $Id: RequestTypeConstants.java, v 0.1 2020年07月13日 9:18 PM liuzunfei Exp $
*/
public class RequestTypeConstants {
-
- public static final String HEART_BEAT="HEART_BEAT";
-
+
+ public static final String HEART_BEAT = "HEART_BEAT";
+
}
diff --git a/api/src/main/java/com/alibaba/nacos/api/remote/response/ServerPushResponse.java b/api/src/main/java/com/alibaba/nacos/api/remote/response/ServerPushResponse.java
new file mode 100644
index 000000000..e244bd100
--- /dev/null
+++ b/api/src/main/java/com/alibaba/nacos/api/remote/response/ServerPushResponse.java
@@ -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 responseId.
+ *
+ * @return property value of responseId
+ */
+ public String getResponseId() {
+ return responseId;
+ }
+
+ /**
+ * Setter method for property responseId.
+ *
+ * @param responseId value to be assigned to property responseId
+ */
+ public void setResponseId(String responseId) {
+ this.responseId = responseId;
+ }
+}
\ No newline at end of file
diff --git a/client/src/main/java/com/alibaba/nacos/client/config/NacosConfigService.java b/client/src/main/java/com/alibaba/nacos/client/config/NacosConfigService.java
index 034520315..0a8f8b9dd 100644
--- a/client/src/main/java/com/alibaba/nacos/client/config/NacosConfigService.java
+++ b/client/src/main/java/com/alibaba/nacos/client/config/NacosConfigService.java
@@ -217,7 +217,6 @@ public class NacosConfigService implements ConfigService {
}
}
-
private boolean removeConfigInRpc(String tenant, String dataId, String group, String tag) {
try {
diff --git a/client/src/main/java/com/alibaba/nacos/client/config/http/HttpAgent.java b/client/src/main/java/com/alibaba/nacos/client/config/http/HttpAgent.java
index e1cda647b..61c59f59c 100644
--- a/client/src/main/java/com/alibaba/nacos/client/config/http/HttpAgent.java
+++ b/client/src/main/java/com/alibaba/nacos/client/config/http/HttpAgent.java
@@ -31,7 +31,7 @@ import java.util.Map;
public interface HttpAgent extends Closeable {
/**
- * get server list manager
+ * get server list manager.
* @return
*/
ServerListManager getServerListManager();
diff --git a/client/src/main/java/com/alibaba/nacos/client/config/impl/ClientWorker.java b/client/src/main/java/com/alibaba/nacos/client/config/impl/ClientWorker.java
index f4068f83e..c47b84912 100644
--- a/client/src/main/java/com/alibaba/nacos/client/config/impl/ClientWorker.java
+++ b/client/src/main/java/com/alibaba/nacos/client/config/impl/ClientWorker.java
@@ -92,6 +92,7 @@ public class ClientWorker implements Closeable {
}
try {
+
rpcClientProxy.listenConfigChange(dataId, group, "");
} catch (NacosException e) {
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()) {
this.executor.scheduleWithFixedDelay(new Runnable() {
@Override
@@ -640,10 +643,8 @@ public class ClientWorker implements Closeable {
}
}
}, 1L, 10L, TimeUnit.MILLISECONDS);
-
+
} else {
- rpcClientProxy = new ConfigGrpcClientProxy();
-
rpcClientProxy.initAndStart(new ServerListFactory() {
@Override
public String genNextServer() {
@@ -651,13 +652,13 @@ public class ClientWorker implements Closeable {
serverListManager.refreshCurrentServerAddr();
return serverListManager.getCurrentServerAddr();
}
-
+
@Override
public String getCurrentServer() {
return agent.getServerListManager().getCurrentServerAddr();
}
});
-
+
/*
* 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) {
LOGGER.error("[{}] [listen] {},{},{}", "grpc", cacheData.dataId, cacheData.group,
cacheData.tenant, e);
-
+
}
}
}
diff --git a/client/src/main/java/com/alibaba/nacos/client/config/remote/ConfigGrpcClientProxy.java b/client/src/main/java/com/alibaba/nacos/client/config/remote/ConfigGrpcClientProxy.java
index 47aaa3b0f..785ffcbab 100644
--- a/client/src/main/java/com/alibaba/nacos/client/config/remote/ConfigGrpcClientProxy.java
+++ b/client/src/main/java/com/alibaba/nacos/client/config/remote/ConfigGrpcClientProxy.java
@@ -120,10 +120,10 @@ public class ConfigGrpcClientProxy {
/**
* publish config.
*
- * @param dataid
- * @param group
- * @param tenat
- * @return
+ * @param dataid dataid
+ * @param group group
+ * @param tenat tenat
+ * @return push result.
* @throws NacosException throw where publish fail.
*/
public ConfigPubishResponse publishConfig(String dataid, String group, String tenat, String content)
@@ -136,10 +136,10 @@ public class ConfigGrpcClientProxy {
/**
* remove config.
*
- * @param dataid
- * @param group
- * @param tenat
- * @return
+ * @param dataid dataid
+ * @param group group
+ * @param tenat tenat
+ * @return response.
* @throws NacosException throw where publish fail.
*/
public ConfigRemoveResponse removeConfig(String dataid, String group, String tenat, String tag)
diff --git a/client/src/main/java/com/alibaba/nacos/client/remote/ConnectionEventListener.java b/client/src/main/java/com/alibaba/nacos/client/remote/ConnectionEventListener.java
index d5a900672..5c5f2441d 100644
--- a/client/src/main/java/com/alibaba/nacos/client/remote/ConnectionEventListener.java
+++ b/client/src/main/java/com/alibaba/nacos/client/remote/ConnectionEventListener.java
@@ -13,27 +13,28 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package com.alibaba.nacos.client.remote;
/**
+ * Client:ConnectionEventListener.
* @author liuzunfei
* @version $Id: ConnectionEventListener.java, v 0.1 2020年07月14日 10:59 AM liuzunfei Exp $
*/
public interface ConnectionEventListener {
-
-
+
/**
- *
+ * notify when server is connected .
*/
public void onConnected();
/**
- *
+ * notify when this client is switch to a new server and is sucessful reconnected .
*/
public void onReconnected();
/**
- *
+ * notify when server is disconnected .
*/
public void onDisConnect();
}
diff --git a/client/src/main/java/com/alibaba/nacos/client/remote/RpcClientFactory.java b/client/src/main/java/com/alibaba/nacos/client/remote/RpcClientFactory.java
index 111772002..05a42ff00 100644
--- a/client/src/main/java/com/alibaba/nacos/client/remote/RpcClientFactory.java
+++ b/client/src/main/java/com/alibaba/nacos/client/remote/RpcClientFactory.java
@@ -22,7 +22,7 @@ import java.util.HashMap;
import java.util.Map;
/**
- * RpcClientFactory.to support muti client for diffrent client.
+ * RpcClientFactory.to support muti client for diffrent modules of usage.
*
* @author liuzunfei
* @version $Id: RpcClientFactory.java, v 0.1 2020年07月14日 3:41 PM liuzunfei Exp $
@@ -34,29 +34,16 @@ public class RpcClientFactory {
static Map clientMap = new HashMap();
public static RpcClient getClient(String module) {
- String useIndependentClient = System.getProperty("rpc.client.independent");
- if ("Y".equalsIgnoreCase(useIndependentClient)) {
+ synchronized (clientMap) {
if (clientMap.get(module) == null) {
RpcClient moduleClient = new GrpcClient();
- return 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;
- }
- }
+ clientMap.putIfAbsent(module, moduleClient);
}
+
+ return clientMap.get(module);
+
}
+
}
}
diff --git a/client/src/main/java/com/alibaba/nacos/client/remote/ServerListFactory.java b/client/src/main/java/com/alibaba/nacos/client/remote/ServerListFactory.java
index ec09ddea1..8b226435e 100644
--- a/client/src/main/java/com/alibaba/nacos/client/remote/ServerListFactory.java
+++ b/client/src/main/java/com/alibaba/nacos/client/remote/ServerListFactory.java
@@ -17,15 +17,23 @@
package com.alibaba.nacos.client.remote;
/**
- *
+ * server list factory . use to inner client to connecte and switch servers.
* @author liuzunfei
* @version $Id: ServerListFactory.java, v 0.1 2020年07月14日 1:11 PM liuzunfei Exp $
*/
public interface ServerListFactory {
-
+ /**
+ * switch to a new server and get it.
+ *
+ * @return
+ */
String genNextServer();
-
+
+ /**
+ * get current server.
+ * @return
+ */
String getCurrentServer();
}
diff --git a/client/src/main/java/com/alibaba/nacos/client/remote/grpc/GrpcClient.java b/client/src/main/java/com/alibaba/nacos/client/remote/grpc/GrpcClient.java
index 593119251..bd0506f59 100644
--- a/client/src/main/java/com/alibaba/nacos/client/remote/grpc/GrpcClient.java
+++ b/client/src/main/java/com/alibaba/nacos/client/remote/grpc/GrpcClient.java
@@ -48,7 +48,6 @@ import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Consumer;
/**
@@ -67,8 +66,6 @@ public class GrpcClient extends RpcClient {
protected RequestGrpc.RequestBlockingStub grpcServiceStub;
- private ReentrantLock startClientLock = new ReentrantLock();
-
ScheduledExecutorService executorService = new ScheduledThreadPoolExecutor(5, new ThreadFactory() {
@Override
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;
@@ -119,14 +116,15 @@ public class GrpcClient extends RpcClient {
// loop until start client success.
while (!isRunning()) {
-
+
buildClientAtFirstTime();
boolean sucess = serverCheck();
if (sucess) {
if (rpcClientStatus.get() == RpcClientStatus.RE_CONNECTING) {
notifyReConnected();
}
- System.out.println("Current Server..." + getServerListFactory().getCurrentServer());
+ LOGGER.info("Server check success, Current Server is {}" + getServerListFactory()
+ .getCurrentServer());
rpcClientStatus.compareAndSet(rpcClientStatus.get(), RpcClientStatus.RUNNING);
reConnectTimesLeft.set(MAX_RECONNECT_TIMES);
@@ -332,6 +330,7 @@ public class GrpcClient extends RpcClient {
GrpcResponse response = grpcServiceStub.request(grpcrequest);
String type = response.getType();
String bodyString = response.getBody().getValue().toStringUtf8();
+
// transfrom grpcResponse to response model
Class classByType = ResponseRegistry.getClassByType(type);
if (classByType != null) {
@@ -343,7 +342,7 @@ public class GrpcClient extends RpcClient {
return (PlainBodyResponse) myresponse;
}
} 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);
}
}
diff --git a/client/src/test/java/com/alibaba/nacos/client/ConfigTest.java b/client/src/test/java/com/alibaba/nacos/client/ConfigTest.java
index f3f2891b2..153929d5c 100644
--- a/client/src/test/java/com/alibaba/nacos/client/ConfigTest.java
+++ b/client/src/test/java/com/alibaba/nacos/client/ConfigTest.java
@@ -38,10 +38,11 @@ public class ConfigTest {
@Before
public void before() throws Exception {
Properties properties = new Properties();
- //properties.setProperty(PropertyKeyConst.SERVER_ADDR, "127.0.0.1:28848");
- properties.setProperty(PropertyKeyConst.SERVER_ADDR,
- "11.239.114.187:8848,11.239.113.204:8848,11.239.112.161:8848");
-
+ properties.setProperty(PropertyKeyConst.SERVER_ADDR, "127.0.0.1:28848");
+ // 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");
+
configService = NacosFactory.createConfigService(properties);
}
@@ -50,7 +51,6 @@ public class ConfigTest {
configService.shutDown();
}
-
@Test
public void test() throws Exception {
@@ -58,27 +58,19 @@ public class ConfigTest {
final String group = "lessspring";
final String content = "lessspring-" + System.currentTimeMillis();
boolean result = configService.publishConfig(dataId, group, content);
- // Assert.assertTrue(result);
-
+ Assert.assertTrue(result);
+
ThreadUtils.sleep(200L);
- ConfigListener1 listener1 = new ConfigListener1();
- ConfigListener2 listener2 = new ConfigListener2();
-
- configService.getConfigAndSignListener(dataId, group, 5000, listener1);
-
- 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.getConfigAndSignListener(dataId, group, 5000, new AbstractListener() {
+ @Override
+ public void receiveConfigInfo(String configInfo) {
+ System.out.println("receiveConfigInfo :" + configInfo);
+ }
+ });
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");
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);
- }
}
\ No newline at end of file
diff --git a/config/src/main/java/com/alibaba/nacos/config/server/remote/ConfiRemoveRequestHandler.java b/config/src/main/java/com/alibaba/nacos/config/server/remote/ConfiRemoveRequestHandler.java
index ab02073b3..6c96abb7e 100644
--- a/config/src/main/java/com/alibaba/nacos/config/server/remote/ConfiRemoveRequestHandler.java
+++ b/config/src/main/java/com/alibaba/nacos/config/server/remote/ConfiRemoveRequestHandler.java
@@ -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.TimeUtils;
import com.alibaba.nacos.core.remote.RequestHandler;
+import com.alibaba.nacos.core.utils.Loggers;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -84,7 +85,7 @@ public class ConfiRemoveRequestHandler extends RequestHandler {
return ConfigRemoveResponse.buildSuccessResponse();
} catch (Exception e) {
- e.printStackTrace();
+ Loggers.GRPC_DIGEST.error("remove config error,error msg is {}", e.getMessage(), e);
return ConfigRemoveResponse.buildFailResponse(e.getMessage());
}
}
diff --git a/config/src/main/java/com/alibaba/nacos/config/server/remote/ConfigChangeListenContext.java b/config/src/main/java/com/alibaba/nacos/config/server/remote/ConfigChangeListenContext.java
new file mode 100644
index 000000000..eaa54e2e6
--- /dev/null
+++ b/config/src/main/java/com/alibaba/nacos/config/server/remote/ConfigChangeListenContext.java
@@ -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> groupKeyContext = new HashMap>();
+
+ /**
+ * connectionId-> groupkey set.
+ */
+ private Map> connectionIdContext = new HashMap>();
+
+ /**
+ * add listen .
+ *
+ * @param listenKey listenKey.
+ * @param connectionId connectionId.
+ */
+ public void addListen(String listenKey, String connectionId) {
+
+ // 1.add groupKeyContext
+ Set listenClients = groupKeyContext.get(listenKey);
+ if (listenClients == null) {
+ groupKeyContext.putIfAbsent(listenKey, new HashSet());
+ listenClients = groupKeyContext.get(listenKey);
+ }
+ listenClients.add(connectionId);
+
+ // 2.add connectionIdContext
+ Set 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 connectionIds = groupKeyContext.get(lisnteKey);
+ if (connectionIds != null) {
+ connectionIds.remove(connectionId);
+ }
+
+ //2.remove connectionIdContext
+ Set groupKeys = connectionIdContext.get(connectionId);
+ if (groupKeys != null) {
+ groupKeys.remove(lisnteKey);
+ }
+ }
+
+ public Set 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 groupKeysinner = connectionIdContext.get(connectionId);
+
+ if (groupKeysinner != null) {
+ Set groupKeys = new HashSet(groupKeysinner);
+ for (String groupKey : groupKeys) {
+ removeListen(groupKey, connectionId);
+ }
+ }
+ connectionIdContext.remove(connectionId);
+ }
+}
\ No newline at end of file
diff --git a/config/src/main/java/com/alibaba/nacos/config/server/remote/ConfigChangeListenRequestHandler.java b/config/src/main/java/com/alibaba/nacos/config/server/remote/ConfigChangeListenRequestHandler.java
index bcf78e368..d7ac293af 100644
--- a/config/src/main/java/com/alibaba/nacos/config/server/remote/ConfigChangeListenRequestHandler.java
+++ b/config/src/main/java/com/alibaba/nacos/config/server/remote/ConfigChangeListenRequestHandler.java
@@ -16,8 +16,6 @@
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.ConfigRequestTypeConstants;
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.common.utils.JacksonUtils;
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.google.common.collect.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import java.util.List;
+
/**
* config change listen request handler.
+ *
* @author liuzunfei
* @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 {
@Autowired
- AsyncListenContext asyncListenContext;
+ ConfigChangeListenContext configChangeListenContext;
@Override
public Request parseBodyString(String bodyString) {
return JacksonUtils.toObj(bodyString, ConfigChangeListenRequest.class);
}
-
+
@Override
public Response handle(Request request, RequestMeta requestMeta) throws NacosException {
ConfigChangeListenRequest configChangeListenRequest = (ConfigChangeListenRequest) request;
@@ -60,15 +58,16 @@ public class ConfigChangeListenRequestHandler extends RequestHandler {
String configKey = GroupKey2.getKey(dataId, group, tenant);
String connectionId = requestMeta.getConnectionId();
if (configChangeListenRequest.isCancelListen()) {
- asyncListenContext.removeListen(NacosRemoteConstants.LISTEN_CONTEXT_CONFIG, configKey, connectionId);
+ configChangeListenContext.removeListen(configKey, connectionId);
} else {
- asyncListenContext.addListen(NacosRemoteConstants.LISTEN_CONTEXT_CONFIG, configKey, connectionId);
+ configChangeListenContext.addListen(configKey, connectionId);
}
return ConfigChangeListenResponse.buildSucessResponse();
}
-
+
@Override
public List getRequestTypes() {
return Lists.newArrayList(ConfigRequestTypeConstants.CHANGE_LISTEN_CONFIG_OPERATION);
}
+
}
diff --git a/config/src/main/java/com/alibaba/nacos/config/server/remote/ConfigChangeNotifier.java b/config/src/main/java/com/alibaba/nacos/config/server/remote/ConfigChangeNotifier.java
new file mode 100644
index 000000000..31b5dec66
--- /dev/null
+++ b/config/src/main/java/com/alibaba/nacos/config/server/remote/ConfigChangeNotifier.java
@@ -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 listeners = configChangeListenContext.getListeners(groupKey);
+ if (!CollectionUtils.isEmpty(listeners)) {
+ for (String connectionId : listeners) {
+ rpcPushService.push(connectionId, notifyResponse);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/config/src/main/java/com/alibaba/nacos/config/server/remote/ConfigConnectionEventListener.java b/config/src/main/java/com/alibaba/nacos/config/server/remote/ConfigConnectionEventListener.java
new file mode 100644
index 000000000..b1ea81028
--- /dev/null
+++ b/config/src/main/java/com/alibaba/nacos/config/server/remote/ConfigConnectionEventListener.java
@@ -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());
+ }
+
+}
\ No newline at end of file
diff --git a/config/src/main/java/com/alibaba/nacos/config/server/remote/ConfigQueryRequestHandler.java b/config/src/main/java/com/alibaba/nacos/config/server/remote/ConfigQueryRequestHandler.java
index 6f983192e..965ebce8f 100644
--- a/config/src/main/java/com/alibaba/nacos/config/server/remote/ConfigQueryRequestHandler.java
+++ b/config/src/main/java/com/alibaba/nacos/config/server/remote/ConfigQueryRequestHandler.java
@@ -121,7 +121,7 @@ public class ConfigQueryRequestHandler extends RequestHandler {
}
}
String configType = cacheItem.getType();
- response.setContentType(configType);
+ response.setContentType((null != configType) ? configType : "text");
}
File file = null;
ConfigInfoBase configInfoBase = null;
@@ -134,7 +134,7 @@ public class ConfigQueryRequestHandler extends RequestHandler {
} else {
file = DiskUtil.targetBetaFile(dataId, group, tenant);
}
- response.addLabel("beta", "Y");
+ response.addLabel("isBeta", "Y");
} else {
if (StringUtils.isBlank(tag)) {
if (isUseTag(cacheItem, autoTag)) {
diff --git a/config/src/main/java/com/alibaba/nacos/config/server/service/LongPollingService.java b/config/src/main/java/com/alibaba/nacos/config/server/service/LongPollingService.java
index d03298738..72ac7547c 100755
--- a/config/src/main/java/com/alibaba/nacos/config/server/service/LongPollingService.java
+++ b/config/src/main/java/com/alibaba/nacos/config/server/service/LongPollingService.java
@@ -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.event.LocalDataChangeEvent;
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.GroupKey;
import com.alibaba.nacos.config.server.utils.LogUtil;
import com.alibaba.nacos.config.server.utils.MD5Util;
import com.alibaba.nacos.config.server.utils.RequestUtil;
-
-import com.alibaba.nacos.core.remote.DataChangeListenerNotifier;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -74,7 +73,7 @@ public class LongPollingService {
private static final String TRUE_STR = "true";
@Autowired
- private DataChangeListenerNotifier dataChangeListenerNotifier;
+ private ConfigChangeNotifier configChangeNotifier;
private Map retainIps = new ConcurrentHashMap();
@@ -366,7 +365,7 @@ public class LongPollingService {
String tenant = strings.length > 2 ? strings[2] : "";
ConfigChangeNotifyResponse notifyResponse = ConfigChangeNotifyResponse
.buildSuccessResponse(dataid, group, tenant);
- dataChangeListenerNotifier.configDataChanged(groupKey, notifyResponse);
+ configChangeNotifier.configDataChanged(groupKey, notifyResponse);
} catch (Throwable t) {
LogUtil.DEFAULT_LOG.error("data change error: {}", ExceptionUtil.getStackTrace(t));
diff --git a/config/src/main/java/com/alibaba/nacos/config/server/utils/ParamUtils.java b/config/src/main/java/com/alibaba/nacos/config/server/utils/ParamUtils.java
index 88fe854b0..fbd9b9467 100644
--- a/config/src/main/java/com/alibaba/nacos/config/server/utils/ParamUtils.java
+++ b/config/src/main/java/com/alibaba/nacos/config/server/utils/ParamUtils.java
@@ -155,5 +155,4 @@ public class ParamUtils {
}
}
-
}
diff --git a/core/src/main/java/com/alibaba/nacos/core/remote/ClientConnectionEventListener.java b/core/src/main/java/com/alibaba/nacos/core/remote/ClientConnectionEventListener.java
index 0d1c4da29..ac3e1aa62 100644
--- a/core/src/main/java/com/alibaba/nacos/core/remote/ClientConnectionEventListener.java
+++ b/core/src/main/java/com/alibaba/nacos/core/remote/ClientConnectionEventListener.java
@@ -17,6 +17,9 @@
package com.alibaba.nacos.core.remote;
import com.alibaba.nacos.api.remote.connection.Connection;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import javax.annotation.PostConstruct;
/**
* ClientConnectionEventListener.
@@ -24,20 +27,51 @@ import com.alibaba.nacos.api.remote.connection.Connection;
* @author liuzunfei
* @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 name.
+ *
+ * @return property value of name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Setter method for property name.
+ *
+ * @param name value to be assigned to property name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
/**
* notified when a client connected.
*
* @param connect connect.
*/
- public void clientConnected(Connection connect);
+ public abstract void clientConnected(Connection connect);
/**
* notified when a client disconnected.
*
* @param connect connect.
*/
- public void clientDisConnected(Connection connect);
+ public abstract void clientDisConnected(Connection connect);
}
\ No newline at end of file
diff --git a/core/src/main/java/com/alibaba/nacos/core/remote/ClientConnectionEventListenerRegistry.java b/core/src/main/java/com/alibaba/nacos/core/remote/ClientConnectionEventListenerRegistry.java
new file mode 100644
index 000000000..a581d24b5
--- /dev/null
+++ b/core/src/main/java/com/alibaba/nacos/core/remote/ClientConnectionEventListenerRegistry.java
@@ -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 clientConnectionEventListeners = new ArrayList();
+
+ /**
+ * register ClientConnectionEventListener.
+ *
+ * @param listener listener.
+ */
+ public void registerClientConnectionEventListener(ClientConnectionEventListener listener) {
+ Loggers.GRPC.info("[ClientConnectionEventListenerRegistry] registry listener - " + listener.getClass().getSimpleName());
+ this.clientConnectionEventListeners.add(listener);
+ }
+
+}
\ No newline at end of file
diff --git a/core/src/main/java/com/alibaba/nacos/core/remote/ConnectCoordinator.java b/core/src/main/java/com/alibaba/nacos/core/remote/ConnectCoordinator.java
index 349ad7e99..86d0c5413 100644
--- a/core/src/main/java/com/alibaba/nacos/core/remote/ConnectCoordinator.java
+++ b/core/src/main/java/com/alibaba/nacos/core/remote/ConnectCoordinator.java
@@ -22,9 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@@ -39,14 +37,15 @@ import java.util.concurrent.TimeUnit;
@Service
public class ConnectCoordinator implements ConnectionHeathyChecker {
- final List clientConnectionEventListeners = new ArrayList();
+ @Autowired
+ private ClientConnectionEventListenerRegistry clientConnectionEventListenerRegistry;
@Autowired
ConnectionManager connectionManager;
private ScheduledExecutorService executors = Executors.newScheduledThreadPool(1);
- private static final long EXPIRE_MILLSECOND = 15000L;
+ private static final long EXPIRE_MILLSECOND = 10000L;
/**
* Start Task:Expel the connection which active Time expire.
@@ -69,7 +68,7 @@ public class ConnectCoordinator implements ConnectionHeathyChecker {
connectionManager.unregister(conn.getConnectionId());
Loggers.GRPC.info("expire connection found ,success expel connectionid = {} ",
conn.getConnectionId());
- for (ClientConnectionEventListener listener : clientConnectionEventListeners) {
+ for (ClientConnectionEventListener listener : clientConnectionEventListenerRegistry.clientConnectionEventListeners) {
listener.clientDisConnected(conn);
}
@@ -83,8 +82,4 @@ public class ConnectCoordinator implements ConnectionHeathyChecker {
}, 500L, 5000L, TimeUnit.MILLISECONDS);
}
- public void registerClientConnectionEventListener(ClientConnectionEventListener listener) {
- this.clientConnectionEventListeners.add(listener);
- }
-
}
diff --git a/core/src/main/java/com/alibaba/nacos/core/remote/ConnectionHeathyChecker.java b/core/src/main/java/com/alibaba/nacos/core/remote/ConnectionHeathyChecker.java
index eea8d42e0..0c82363bb 100644
--- a/core/src/main/java/com/alibaba/nacos/core/remote/ConnectionHeathyChecker.java
+++ b/core/src/main/java/com/alibaba/nacos/core/remote/ConnectionHeathyChecker.java
@@ -13,9 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package com.alibaba.nacos.core.remote;
/**
+ * ConnectionHeathyChecker.
* @author liuzunfei
* @version $Id: ConnectionHeathyChecker.java, v 0.1 2020年07月14日 12:01 AM liuzunfei Exp $
*/
diff --git a/core/src/main/java/com/alibaba/nacos/core/remote/ConnectionManager.java b/core/src/main/java/com/alibaba/nacos/core/remote/ConnectionManager.java
index a5d985a56..53490b144 100644
--- a/core/src/main/java/com/alibaba/nacos/core/remote/ConnectionManager.java
+++ b/core/src/main/java/com/alibaba/nacos/core/remote/ConnectionManager.java
@@ -20,9 +20,7 @@ import com.alibaba.nacos.api.remote.connection.Connection;
import com.alibaba.nacos.core.utils.Loggers;
import org.springframework.stereotype.Service;
-import java.util.ArrayList;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
/**
@@ -36,7 +34,6 @@ public class ConnectionManager {
Map connetions = new HashMap();
-
/**
* register a new connect.
*
diff --git a/core/src/main/java/com/alibaba/nacos/core/remote/NacosRemoteConstants.java b/core/src/main/java/com/alibaba/nacos/core/remote/NacosRemoteConstants.java
index eb7031ff5..b45930ddc 100644
--- a/core/src/main/java/com/alibaba/nacos/core/remote/NacosRemoteConstants.java
+++ b/core/src/main/java/com/alibaba/nacos/core/remote/NacosRemoteConstants.java
@@ -28,5 +28,4 @@ public class NacosRemoteConstants {
public static final String LISTEN_CONTEXT_NAMING = "NAMING";
-
}
diff --git a/core/src/main/java/com/alibaba/nacos/core/remote/PushCallBack.java b/core/src/main/java/com/alibaba/nacos/core/remote/PushCallBack.java
new file mode 100644
index 000000000..8955ccbca
--- /dev/null
+++ b/core/src/main/java/com/alibaba/nacos/core/remote/PushCallBack.java
@@ -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();
+
+}
\ No newline at end of file
diff --git a/core/src/main/java/com/alibaba/nacos/core/remote/RpcPushService.java b/core/src/main/java/com/alibaba/nacos/core/remote/RpcPushService.java
new file mode 100644
index 000000000..3a670d07d
--- /dev/null
+++ b/core/src/main/java/com/alibaba/nacos/core/remote/RpcPushService.java
@@ -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);
+ }
+
+}
\ No newline at end of file
diff --git a/core/src/main/java/com/alibaba/nacos/core/remote/RpcServer.java b/core/src/main/java/com/alibaba/nacos/core/remote/RpcServer.java
index 2e51b6033..da4972968 100644
--- a/core/src/main/java/com/alibaba/nacos/core/remote/RpcServer.java
+++ b/core/src/main/java/com/alibaba/nacos/core/remote/RpcServer.java
@@ -23,13 +23,6 @@ package com.alibaba.nacos.core.remote;
*/
public abstract class RpcServer {
- /**
- * register a ClientConnectionEventListener.
- *
- * @param eventListener eventListener.
- */
- public abstract void registerClientConnectionEventListener(ClientConnectionEventListener eventListener);
-
/**
* Start sever.
*/
diff --git a/core/src/main/java/com/alibaba/nacos/core/remote/grpc/GrpcConnection.java b/core/src/main/java/com/alibaba/nacos/core/remote/grpc/GrpcConnection.java
index 3636a811e..7ab298a54 100644
--- a/core/src/main/java/com/alibaba/nacos/core/remote/grpc/GrpcConnection.java
+++ b/core/src/main/java/com/alibaba/nacos/core/remote/grpc/GrpcConnection.java
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package com.alibaba.nacos.core.remote.grpc;
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;
/**
+ * grpc connection.
* @author liuzunfei
* @version $Id: GrpcConnection.java, v 0.1 2020年07月13日 7:26 PM liuzunfei Exp $
*/
public class GrpcConnection extends Connection {
-
+
private StreamObserver streamObserver;
-
- public GrpcConnection(ConnectionMetaInfo metaInfo,StreamObserver streamObserver) {
+
+ public GrpcConnection(ConnectionMetaInfo metaInfo, StreamObserver streamObserver) {
super(metaInfo);
- this.streamObserver=streamObserver;
+ this.streamObserver = streamObserver;
}
-
+
@Override
public void sendResponse(Response reponse) {
streamObserver.onNext(GrpcUtils.convert(reponse));
}
-
-
-
+
@Override
public void closeGrapcefully() {
//Empty implements
diff --git a/core/src/main/java/com/alibaba/nacos/core/remote/grpc/GrpcServer.java b/core/src/main/java/com/alibaba/nacos/core/remote/grpc/GrpcServer.java
index 73497ed03..c6da0fdc2 100644
--- a/core/src/main/java/com/alibaba/nacos/core/remote/grpc/GrpcServer.java
+++ b/core/src/main/java/com/alibaba/nacos/core/remote/grpc/GrpcServer.java
@@ -16,7 +16,7 @@
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.ConnectionManager;
import com.alibaba.nacos.core.remote.RequestHandlerRegistry;
@@ -41,6 +41,8 @@ public class GrpcServer extends RpcServer {
private Server server;
+ @Autowired
+ private ClientConnectionEventListenerRegistry clientConnectionEventListenerRegistry;
@Autowired
private ConnectCoordinator connectCoordinator;
@@ -68,11 +70,6 @@ public class GrpcServer extends RpcServer {
Loggers.GRPC.info("Request handler Registry inited :" + requestHandlerRegistry);
}
- @Override
- public void registerClientConnectionEventListener(ClientConnectionEventListener eventListener) {
- connectCoordinator.registerClientConnectionEventListener(eventListener);
- }
-
@PostConstruct
@Override
public void start() throws Exception {
diff --git a/pom.xml b/pom.xml
index 860629431..61479b12e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1016,17 +1016,72 @@
-
-
-
-
- sona
- https://oss.sonatype.org/content/repositories/snapshots/
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
- sona
- https://oss.sonatype.org/service/local/staging/deploy/maven2/
+ central
+ http://mvnrepo.alibaba-inc.com/mvn/repository
+
+ true
+
+
+ false
+
+
+ snapshots
+ http://mvnrepo.alibaba-inc.com/mvn/repository
+
+ false
+
+
+ true
+
+
+
+
+
+ central
+ http://mvnrepo.alibaba-inc.com/mvn/repository
+
+ true
+
+
+ false
+
+
+
+ snapshots
+ http://mvnrepo.alibaba-inc.com/mvn/repository
+
+ false
+
+
+ true
+
+
+
+
+
+ releases
+ http://mvnrepo.alibaba-inc.com/mvn/releases
+
+
+ snapshots
+ http://mvnrepo.alibaba-inc.com/mvn/snapshots
+